Skip to content

Remove ANSI color codes from a log

Paste output from a terminal, a CI job or docker logs. Get plain text back, or see the colors the way the terminal showed them.

What the codes are

Terminals color text with escape sequences: an invisible ESC character followed by something like [31m for red and [0m to reset. Saved to a file, they turn into clutter. Depending on what handled the log on the way, ESC shows up as nothing, as ^[, or spelled out as \u001b, \x1b or \033. This page removes all of those spellings, along with cursor movement and terminal title sequences.

To stop a program writing the codes in the first place, most tools honor the NO_COLOR environment variable or a --no-color flag. Remove or display ANSI codes in a log covers Docker, npm and other common sources.

Where the codes come from

Most command-line tools color their output only when they think a person is watching a terminal. CI services and container platforms often turn color on anyway, because their own web views show it, so a log downloaded from a CI job or saved from docker logs is where the codes usually turn up. Copying from a web log viewer or out of a JSON log can bring the escaped spellings with it instead of the invisible character.

Clean text is what you want for a bug report, a diff or a search. The colored preview is for reading: an error in red is easier to spot than the same line in gray.

FAQ

Is the text I paste sent anywhere?

No. The cleaning happens in your browser, so it is safe for logs with internal hostnames or tokens.

The site does count page views with Google Analytics, which is never given your files or anything you type. Privacy has the details.

Can I strip codes on the command line instead?

Yes. sed 's/\x1b\[[0-9;]*m//g' file.log removes the common color codes. The page also handles the escaped spellings and non-color sequences, and is quicker for a one-off paste.

Does it change anything besides the codes?

No. Only the escape sequences are taken out; the words, spacing and line breaks stay exactly as they were. A terminal hyperlink keeps its visible text and loses the hidden address.

Which colors does the preview support?

The 16 standard colors, the 256-color palette and 24-bit color, plus bold, dim, italic and underline.

Reading colored logs on a Mac?

Log Viewer shows ANSI colors as color in files of any size, and filters, follows and compares them too.

See what Log Viewer does

FreemacOSDownload on the Mac App Store (opens in a new tab)