1. Home
  2. Developer tools
  3. ANSI Escape Codes

ANSI Escape Codes

Colour your CLI output, decode the strange characters in a log file, or look up what ^[ and \x1b mean.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use ANSI Escape Codes

  1. Pick colours and styles to build a sequence, or paste output to preview.
  2. Copy the code for your language.
  3. Look up control characters and SGR codes in the tables.

Features

  • Builder for 8 normal and 8 bright colours, bold and underline
  • Code for Bash printf, Node, Python and PowerShell 7
  • Preview that renders 16-colour, 256-colour and true-colour codes
  • C0 control codes 0–31 and DEL with caret and escape notation
  • SGR, cursor movement, clear screen, hyperlinks (OSC 8) and titles

Supported formats

Input

  • Typed or pasted text

You get

  • Copied text

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the ANSI Escape Codes is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Colours shown are typical defaults; each terminal theme maps the 16 basic colours differently.

Guide

ANSI escape sequences and ASCII control characters explained

Terminals show colour and formatting because programs print invisible control characters among the text. The most common are ANSI escape sequences, which start with the ESC character and tell the terminal to change colour, move the cursor or clear the screen. Seeing [31m or ^[[0m scattered through a log file means those sequences were captured without a terminal to interpret them. This page builds sequences, previews them and explains the control characters behind them.

What an escape sequence is

An escape sequence begins with the ESC character, byte 27 or 0x1B, followed by [ and a list of numbers separated by semicolons, and ends with a letter that names the command. The letter m means “select graphic rendition” (SGR): \x1b[1;31m switches to bold red, and \x1b[0m resets everything. The standard behind them is ECMA-48, and xterm added the extensions most terminals share today.

Colours: 16, 256 and true colour

Codes 30 to 37 select the eight standard foreground colours and 90 to 97 the bright ones; 40 to 47 and 100 to 107 do the same for backgrounds. For more colours, 38;5;n picks from a 256-colour palette (16 basic, a 6×6×6 colour cube and 24 greys), and 38;2;r;g;b gives any 24-bit colour. Use 48 instead of 38 for backgrounds. Only the first 16 depend on the terminal’s theme.

Writing them in your language

The colour builder shows the same sequence for four environments. In Bash, printf '\x1b[1;31m%s\x1b[0m\n' "text" is portable, while echo needs the -e option. Node uses console.log('\x1b[1;31m%s\x1b[0m', 'text'). Python accepts "\033[1;31mtext\033[0m". PowerShell 7 writes the escape as a backtick followed by e. Always end with the reset code, or the colour leaks into whatever the shell prints next.

Control characters

Below ESC sit 32 control codes, 0 to 31, plus DEL at 127. Many survive in daily use: LF (10) ends a line on Unix, CR (13) returns the cursor, HT (9) is the tab, BEL (7) beeps, and ESC (27) starts sequences. Caret notation writes control code n as ^ followed by the letter at 64 + n, so Ctrl+C is ^C (code 3) and ESC is ^[. The table lets you search by name, number or caret form.

A worked example

The preview’s Sample prints four lines. Bold green ✔ build, yellow warning, bold red error with the file name underlined, and a line using the 256-colour code 208 for orange and true-colour 99, 102, 241 for indigo. In the preview the green is rendered as rgb(13, 188, 121) and the orange as rgb(255, 135, 0). Searching the control-code table for ^[ finds the row 27 0x1B ESC Escape ^[.

Cleaning logs

Programs usually colour output only when connected to a terminal, but CI systems and script captures often keep the codes. To strip them, remove each ESC followed by [, digits and semicolons, and a letter, for instance with sed -r "s/\x1b\[[0-9;]*[A-Za-z]//g". The preview’s “copy without codes” button does the same for pasted text.

Windows and other limits

Windows Terminal and PowerShell 7 interpret sequences by default; the legacy console window needs virtual-terminal processing enabled. The preview only renders colours and text styles. Cursor movement, screen clearing and the alternate screen are listed in the reference but not emulated.

Checked against the current version of the ANSI Escape Codes on .

Frequently asked questions

What is the difference between \x1b, \033 and \e?

They are three spellings of the same byte, 27 in decimal or 1B in hex. C and Python accept \x1b and \033 (the latter is octal), Bash’s echo -e and printf accept \e or \033, and JavaScript strings accept \x1b and \u001b.

Why do my colours look different on another machine?

The 16 basic colours are only names: each terminal theme decides which RGB value red or blue has. The 256-colour cube and true-colour codes use fixed values, so they look the same everywhere that supports them.

Why do I see ←[31m instead of colours on Windows?

The console is not in virtual-terminal mode. Windows Terminal and PowerShell 7 enable it by default; in the old conhost window, run your program inside Windows Terminal or enable ENABLE_VIRTUAL_TERMINAL_PROCESSING.

How do I strip colour codes from a log?

Remove sequences that match ESC [ followed by digits and semicolons and a final letter: sed -r "s/\x1b\[[0-9;]*[A-Za-z]//g". The preview tab also has a “copy without codes” button.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.