ANSI truecolor generator
The ANSI truecolor escape generator turns a familiar hexadecimal or RGB color into the exact Select Graphic Rendition sequence used by terminals with twenty-four-bit color support.
Run — free
Enter a short or full hexadecimal value, or an rgb() color, and choose foreground or background output. The result includes the real escape character for direct use, a visibly escaped form that is convenient in source code and configuration, normalized channel values, and the standard reset sequence. It is deterministic, fast, and useful for shell tools, build scripts, logging systems, and command-line interfaces.
Choose a color and the part of the terminal to change
Start with a color in one of the accepted forms: three-digit hexadecimal such as <code>#3af</code>, six-digit hexadecimal such as <code>#33AAFF</code>, the same six digits without a hash, or an RGB function such as <code>rgb(51, 170, 255)</code>. Hexadecimal letters are case-insensitive, and whitespace inside the RGB function is allowed. Every RGB channel must be a whole number from zero through 255. Then select whether the color applies to the foreground, which normally means text, or the background behind the text. The default is foreground because that is the most common need for command output. The generator expands shorthand hexadecimal values, normalizes the final color to uppercase six-digit hexadecimal, and returns the decimal red, green, and blue channels. This makes the result easy to audit before inserting it into a script. It deliberately rejects alpha channels, CSS color names, percentages, and out-of-range channels because ANSI truecolor sequences encode exactly three eight-bit color channels and have no alpha component. Clear validation keeps an accidental CSS value from silently becoming an unexpected terminal color.
Use the generated escape sequence safely
A twenty-four-bit ANSI color uses an escape character followed by an SGR parameter list. Foreground colors begin with <code>38;2</code>, while background colors begin with <code>48;2</code>; the three decimal channels follow in red, green, blue order and the sequence ends with <code>m</code>. The response provides two representations of the same instruction. The <code>sequence</code> field contains the actual ESC control character, so a program can concatenate it directly with text. The <code>escaped</code> field begins with the visible characters <code>\x1b</code>, which is often easier to copy into JavaScript, shell, JSON templates, or documentation where a literal control character would be confusing. How an escaped string is interpreted depends on its host language, so use the representation appropriate for that environment. Append the returned reset after the colored span so later prompts and log lines do not inherit the style. For example, construct output conceptually as color sequence, message, then reset. Avoid applying color codes to machine-readable output unless consumers explicitly support them, since invisible control characters can break comparisons, parsers, and snapshots.
Understand terminal support and production behavior
Truecolor is widely supported by modern terminal emulators, but the ANSI protocol does not force every output destination to render twenty-four-bit color. A redirected file, a basic terminal, a continuous-integration log viewer, or an application configured to strip styling may show no color or expose control characters. Treat color as presentation rather than information: labels, severity names, and status messages should remain understandable when styling is removed. Many command-line programs enable color only when standard output is attached to an interactive terminal and provide a flag or environment setting to force or disable it. This generator does not inspect the caller's terminal, because doing so would make a pure API result depend on an unrelated runtime. It simply creates the correct byte sequence for the requested color. The algorithm performs no network requests, uses no randomness, and preserves no input. Identical inputs therefore return identical JSON. API use costs $0.002 per request, while the browser execution path uses the same pure conversion logic. For logging systems, consider inserting sequences only at the final human-facing renderer rather than storing them in structured events; that keeps searches and downstream exports clean while preserving attractive console output.
What you can do with it
Color command-line status messages
Generate exact foreground sequences for success, warning, and failure labels while keeping the palette in ordinary HEX notation.
Style development logs
Create foreground or background codes for a human-facing console formatter and append the supplied reset after every styled segment.
Convert design colors for terminal themes
Turn colors copied from a design system into normalized RGB channels and ANSI truecolor sequences without manual decimal conversion.
FAQ
What color formats are accepted?
Use #RGB, #RRGGBB, six hexadecimal digits without the hash, or rgb(r, g, b) with integer channels from 0 to 255.
What is the difference between sequence and escaped?
The sequence field contains a real ESC character. The escaped field displays its common \x1b notation for copying into source code or configuration.
How do I stop the color?
Append the returned reset value after the colored text. Its escaped representation is also included for environments that interpret string escapes.
Will every terminal display this color?
No. The destination must support ANSI Select Graphic Rendition sequences and twenty-four-bit truecolor. Redirected or filtered output may not render styling.
What does an API request cost?
Each API request costs $0.002. The conversion is also available through the free browser execution path.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/dev/ansi-truecolor \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"color":"#33A1FF"}'const res = await fetch("https://api.kit.forhosting.com/dev/ansi-truecolor", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"color": "#33A1FF"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/dev/ansi-truecolor",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"color": "#33A1FF"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/dev/ansi-truecolor", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"color":"#33A1FF"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"color":"#33A1FF"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/dev/ansi-truecolor", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"color": "#33A1FF"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "dev.ansi_truecolor",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |