ANSI colors are the sixteen palette slots that a terminal emulator maps to Select Graphic Rendition (SGR) parameter numbers defined in ECMA-48, the standard that governs text styling control sequences. Each slot is addressed by an integer: 30 through 37 for foreground colors and 40 through 47 for backgrounds in the base set, with 90 through 97 and 100 through 107 reserved for the common bright extensions used by xterm-compatible terminals. A complete ANSI color command is a short byte sequence built from the escape character 0x1B, a left bracket, one or more semicolon-separated decimal parameters, and the letter m. Browsers and most modern terminals interpret the same numbers in the same order, so a sequence built from those parameters produces the same logical styling across environments even though the visible color is chosen by the active theme.
Developers encounter ANSI colors whenever they need colored logs, expressive CLI output, syntax-highlighted test reports, or styled text inside a debugging fixture. The challenge is that the sequences are control bytes rather than printable text, so they cannot be authored by typing them into a normal text field. A dedicated builder is the practical way to compose them, inspect their structure, and copy the raw output into a terminal-aware tool. The ANSI Color Codes Generator handles that workflow: it accepts the text you want to style, lets you choose an optional foreground, background, bold, or underline, and emits both a visible escaped representation for review and the exact raw control bytes for the clipboard.

What ANSI Colors Actually Are
The ANSI color system is a subset of a broader family of terminal control sequences standardized in ECMA-48. That document defines Select Graphic Rendition as the mechanism that changes how a terminal renders subsequent characters without moving the cursor or editing the screen. SGR is parameter-driven: every meaningful instruction has a numeric code, and the terminal decides what to do with each code. Color codes are simply the SGR parameters 30 through 37 for foreground and 40 through 47 for background, while the numbers 90 through 97 and 100 through 107 are the widely supported bright counterparts. ECMA-48 defines the base rendition controls, and the bright mappings are an extension documented in xterm's control sequence reference.
The important consequence is that the numbers describe positions in a 16-slot palette rather than literal colors. The terminal, theme, accessibility setting, multiplexer, or remote environment chooses the actual RGB value for each slot. A "bright red" sequence means "use slot 91", and whether slot 91 looks like a soft pink, a saturated fire-engine red, or a high-contrast accessible hue depends entirely on the receiving program. Tools that promise a fixed visual color are making a promise the standard does not support, which is why the generator exposes parameters and slot names rather than sample swatches.
The 16 Standard Color Slots and Their Codes
The table below lists each slot alongside its base foreground SGR code, its bright foreground SGR code, its base background SGR code, and its bright background SGR code. Slot order is the canonical black, red, green, yellow, blue, magenta, cyan, white sequence used throughout the standard.
| Slot name | FG base | FG bright | BG base | BG bright |
|---|---|---|---|---|
| Black | 30 | 90 | 40 | 100 |
| Red | 31 | 91 | 41 | 101 |
| Green | 32 | 92 | 42 | 102 |
| Yellow | 33 | 93 | 43 | 103 |
| Blue | 34 | 94 | 44 | 104 |
| Magenta | 35 | 95 | 45 | 105 |
| Cyan | 36 | 96 | 46 | 106 |
| White | 37 | 97 | 47 | 107 |
Foreground and background combine inside the same SGR sequence by listing both parameters together. Style parameters sit alongside them in the same semicolon-separated list: bold is parameter 1, italic is parameter 3, and underline is parameter 4. The terminal evaluates the entire list and applies each effect, so a single sequence can carry bold, underline, foreground, and background at once without nested escapes.
Anatomy of an SGR Escape Sequence
A complete color command has four structural parts. First is the Control Sequence Introducer, written as the escape byte 0x1B followed by a left square bracket. Next comes a list of decimal parameters separated by semicolons, where each number addresses a slot, a style, or a reset. The sequence ends with the letter m, which identifies the introducer as Select Graphic Rendition. After the m, the styled text appears, and a final ESC[0m clears the rendition so that subsequent output inherits a clean state instead of leaking the previous styling.
Consider a concrete combination: bright red foreground, blue background, bold, and underline. The combined parameter list is 1;4;91;44, which the generator emits as ESC[1;4;91;44m followed by your text and ESC[0m. The visible escaped representation writes the escape byte as the four characters backslash-x-1-b so the structure can be reviewed in a browser without changing the appearance of the page; the Copy button places the actual single-byte escape on the clipboard rather than the literal four characters. Because every parameter is a small integer, the entire directive fits in roughly a dozen bytes and travels through pipes, log files, and source strings with no special handling beyond understanding that it is control data rather than printable text.
Build an ANSI Sequence in Three Steps
The ANSI Color Codes Generator produces the control bytes for any combination of text, foreground, background, bold, and underline. The workflow is the same regardless of where the sequence will eventually be pasted, whether that destination is a source string, a debugging fixture, or a logging pipeline that forwards to a real terminal.
- Enter terminal text and choose optional settings. Type the literal text you want styled into the input area, then pick a foreground and background from the standard 16 slots if needed. Add bold or underline if your target sequence needs them; leave a field unset to omit that parameter entirely and keep the directive as small as possible.
- Generate the sequence and inspect both representations. The generator emits two views side by side. The raw bytes show the actual escape character, parameters, text, and trailing reset; the visible escaped view shows the same structure with the escape byte written as backslash-x-1-b so you can verify the parameter list without triggering control behavior in the browser. Cross-check that the parameter list contains exactly the styles you selected and nothing extra, and that the reset appears at the end of the sequence.
- Copy the raw sequence into a trusted terminal-aware context and test the reset. Use the Copy button to place the actual control bytes on the clipboard, then paste them into a source string, fixture, debugging tool, or terminal that understands ECMA-48. Confirm that the trailing ESC[0m returns later output to the default rendition. If a downstream program does not display the expected color, the receiving theme is remapping the slot rather than the generator producing a wrong code.
All composition, validation, and clipboard work happens in the browser; nothing is uploaded and no shell is executed. Unsupported color or style numbers are rejected up front so the resulting sequence will not silently fall back to a different slot in the destination, and the generator appends a reset whenever a prefix is created so later terminal output is less likely to inherit formatting from an earlier line.
Limits, Themes, and Log Safety
Three practical limits shape every ANSI color workflow. First, the codes name palette slots rather than guarantee an RGB value, so a sequence that looks bright red in one terminal may look muted, accessible-yellow, or a different hue entirely in another. The xterm control sequence documentation is the cross-check for which parameter numbers are broadly implemented across terminal emulators, multiplexers, and remote shells. Second, the generator supports a focused set of styles: bold, italic in logic compatibility, and underline, plus the standard 16 colors. Bold often selects increased intensity on modern terminals rather than a heavier glyph, and some legacy terminals use bold to switch to the bright palette, which can change the visible color without changing the parameter list.
Third, raw escape bytes are control data. Pasting them into a terminal command line, an issue tracker, a chat transcript, or a log file can produce invisible behavior: terminal state can be disrupted, visual lines can be forged, and links can be made misleading. Logs that may contain untrusted input should sanitize control bytes before printing them to an interactive terminal or offer a plainly escaped logging path where control sequences are removed or visibly escaped. ECMA-48 fifth edition is the authoritative source for the SGR grammar, and a generated sequence that targets only the documented parameters is the safest baseline. Smallest parameter sets, visible inspection of the escaped representation, an appended reset, and a final visual check in the actual destination environment are the four guardrails that keep an ANSI color workflow predictable across themes and platforms.
Related reading: How to Use ASCII Code on Mac: A Quick Lookup Reference.