Skip to main content

ANSI Terminal Color Code Generator

Generate ANSI/VT100 terminal escape codes for colored, styled text — pick a foreground/background color and style attributes (bold, underline, blink, etc.) and get the escape sequence plus a ready-to-run shell printf command.

Input

Output

Shown as visible backslash notation (\x1b), not a raw ESC byte, so it's readable and copyable.

Shell Command
 
Was this helpful?

Guides

ANSI escape codes (also called VT100 or SGR — Select Graphic Rendition — codes) are short sequences of characters that terminals, shells, and CLI tools interpret as formatting instructions instead of visible text. A sequence always starts with the ESC byte (\x1b, decimal 27) followed by [, one or more numeric parameters separated by semicolons, and a final m. For example, \x1b[1;31m tells the terminal "turn on bold, then switch the foreground color to red." Everything printed after that sequence is styled accordingly, until a reset code (\x1b[0m) turns formatting back off.

This generator builds those sequences for you from a simple form, so you don't have to memorize the numeric codes or hand-assemble escape strings.

How to use it

  1. Type or paste your sample text into Sample Text.
  2. Pick a Foreground Color and/or Background Color from the 16-color basic palette (8 standard colors plus 8 "bright" variants), or leave either on "None" to skip it.
  3. Toggle any text style attributes you want — Bold, Dim, Italic, Underline, Blink, Reverse video, and Strikethrough.
  4. The tool immediately generates two things:
    • Escape Sequence — the exact code wrapped around your text, shown as readable backslash notation (e.g. \x1b[1;31mHello\x1b[0m) rather than an invisible control byte, so you can see and copy it.
    • Shell Command — a ready-to-run printf command that prints your styled text in a POSIX-compatible shell (bash, zsh, sh).

Paste the escape sequence directly into source code (Python, Node.js, Go, C, etc.) wherever you build strings for terminal output, or run the shell command as-is to preview the result in your own terminal.

FAQ

Why does the output show \x1b as text instead of an actual control character? An unprintable ESC byte can't be usefully displayed, selected, or verified inside a text box — it just looks like nothing (or a stray box glyph). Showing it as the literal four characters \x1b keeps the output readable while still being the exact text you'd type into most languages' string literals (Python, JavaScript, C, Go, Rust, and others all accept \x1b as an escape in double-quoted strings).

Will this work in every terminal? The 16-color basic palette (codes 30-37 and 90-97 for foreground, 40-47 and 100-107 for background) and the SGR style attributes are supported by virtually every modern terminal emulator, as well as most CI log viewers. A few style attributes (blink, in particular) are ignored by some terminals for accessibility reasons.

Do the style codes combine? Yes — pick as many style checkboxes as you like alongside a color; all the SGR parameters are combined into a single sequence, separated by semicolons (e.g. \x1b[1;4;31m for bold + underline + red).

Is my text sent anywhere? No. Everything runs locally in your browser — your sample text and chosen colors never leave your device.

ansiterminalescape codesclicolor codesvt100sgr

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.