ANSI Color Code Reference

Browse all ANSI escape codes for terminal colors and text formatting with click-to-copy sequences.

About This Tool

The ANSI Color Code Reference is a comprehensive browser-based tool for exploring and using ANSI escape sequences in terminal applications. ANSI escape codes are special character sequences that control text formatting, color, and other output options in terminal emulators and console applications.

This tool covers the full spectrum of ANSI color support: the original 16 standard and bright colors (codes 0-15), the extended 256-color palette including the 6x6x6 color cube (codes 16-231) and 24-step grayscale ramp (codes 232-255), and modern 24-bit true color (RGB) support with over 16 million colors. Each color displays its ANSI code, hex value, and a visual preview.

Beyond colors, the reference includes all SGR (Select Graphic Rendition) text formatting codes such as bold, dim, italic, underline, blink, reverse, hidden, and strikethrough. The reset codes section helps you understand how to properly terminate styled output to prevent color bleeding.

Every escape sequence can be copied in five programming language formats: Bash, Python, Node.js, Go, and C. The live preview feature lets you compose styles interactively — choose foreground and background colors, toggle formatting attributes, and instantly see both the visual result and the corresponding code in your preferred language.

All processing happens entirely in your browser. No data is sent to any server, making it safe to use in any environment. Whether you are writing shell scripts, building CLI tools, or adding colored logging to your application, this reference provides everything you need to work with ANSI color codes effectively.

How to Use

  1. Select your preferred output format (Bash, Python, Node.js, Go, or C) using the format buttons at the top.
  2. Browse the Standard tab to see the 16 basic ANSI colors with their foreground and background codes.
  3. Switch to the 256 Colors tab to explore the full 256-color palette including the color cube and grayscale ramp.
  4. Use the True Color tab to pick any RGB color with sliders and get the corresponding 24-bit ANSI escape sequence.
  5. Check the Formatting tab for text style codes like bold, italic, underline, and strikethrough.
  6. Use the Live Preview tab to compose text with custom foreground, background, and style attributes, then copy the generated code.
  7. Click any color cell to see its full details including escape sequences in all supported formats.
  8. Use Ctrl+Shift+C to quickly copy the escape sequence for the currently selected color.

FAQ

Is my data safe when using this tool?

Yes. This tool runs entirely in your browser with no server communication. No data is sent, stored, or logged anywhere. You can safely use it on any network.

What is the difference between 256-color and true color?

The 256-color mode uses a fixed palette of 256 predefined colors accessed with codes 0-255. True color (24-bit) allows you to specify any RGB color with 16.7 million possible values. True color uses the format 38;2;R;G;B for foreground and 48;2;R;G;B for background. Most modern terminals support true color, but some older ones only support 256 colors.

Do all terminals support ANSI color codes?

Most modern terminal emulators support at least the basic 16 colors. The 256-color palette is supported by the vast majority of terminals in use today. True color (24-bit) support varies but is available in iTerm2, Windows Terminal, GNOME Terminal, Alacritty, Kitty, and most other modern terminals. Windows Command Prompt has limited support but Windows Terminal fully supports ANSI codes.

Why should I always use a reset code?

Without a reset code at the end of your colored output, the styling will bleed into subsequent terminal output. The reset code \033[0m clears all formatting attributes. Best practice is to always append a reset sequence after any styled text to prevent unintended color inheritance.

Can I combine multiple ANSI codes?

Yes. You can combine multiple SGR codes by separating them with semicolons within a single escape sequence. For example, \033[1;4;31m applies bold, underline, and red color simultaneously. The live preview feature in this tool lets you compose combinations interactively.

What is the difference between foreground and background codes?

Foreground codes set the text color. For standard colors, foreground codes are 30-37 (standard) and 90-97 (bright). Background codes set the color behind the text, using 40-47 (standard) and 100-107 (bright). For the 256-color palette, foreground uses 38;5;N and background uses 48;5;N.

How do I use ANSI colors in different programming languages?

The escape character is represented differently in each language: Bash and Python use \033, Node.js uses \x1b, Go uses \033, and C uses \033. This tool automatically generates the correct syntax for each language. Simply select your language format at the top and copy the generated code.

Popular ANSI Color Examples

View all ANSI color code examples →

Related Tools