What those strange characters in your logs are
Command-line tools color their output with ANSI escape sequences: short control codes that a terminal interprets instead of printing. ESC[31m switches the text to red, ESC[1m to bold, ESC[0m resets everything. In a terminal you see colored text. Anywhere else — a CI log file, a log aggregator, a ticket, a chat message — you see the codes themselves: [31mERROR[0m, or \x1b[31m, \033[31m or ^[[31m, depending on how the text was captured.
They are more than ugly. They break searches (the word ERROR is now surrounded by invisible bytes), confuse parsers and grok patterns, and make diffs between two runs useless. Stripping them gives you the text the program meant to print.
Colors and styles (SGR)
Sequences ending in m: 16 basic colors, 256-color and 24-bit color, bold, dim, italic, underline. Rendered in the preview.
Cursor movement
Sequences ending in letters such as A, K or G — used by progress bars and spinners. Removed.
Carriage returns
A progress bar redraws one line with \r. In a file that becomes hundreds of copies; the cleaner keeps only the final state.
Titles and hyperlinks (OSC)
Sequences that set the window title or create clickable links. Removed, keeping the visible text.
Stopping the codes at the source
Cleaning afterwards is a workaround. Most tools can be told not to emit color when the output is not a terminal: set the NO_COLOR=1 environment variable (a widely supported convention), or pass --no-color or --color=never. In CI, some tools need TERM=dumb or CI=true. On the command line, sed 's/\x1b\[[0-9;]*[A-Za-z]//g' strips the common sequences from a file.
Frequently asked questions
What are ANSI escape codes?
Control sequences, starting with the ESC character, that tell a terminal to change text color or style, move the cursor or clear the screen. They are instructions for the terminal, not part of the text.
How do I remove color codes from a log file?
Paste the log here and copy the plain text. On a server, use sed 's/\x1b\[[0-9;]*[A-Za-z]//g' file.log, or better, disable color in the tool that writes the log.
Why do I see [0m and [31m in my CI logs?
The tool printed ANSI color codes and the log viewer shows them as text instead of interpreting them — the ESC character itself is invisible, so only the rest of the sequence appears.
Does the tool understand \x1b[ and \033[ written as text?
Yes. Literal \x1b, \u001b, \033, \e and ^[ notations are treated the same as a real ESC character, so logs copied from JSON or from an editor are handled too.