Overview
Introduction
Text copied from a terminal often carries invisible ANSI escape codes for color and boldness, which show up as garbled control characters or stray bracketed numbers once pasted somewhere that doesn't interpret them.
This tool strips those SGR escape sequences back out and hands you the clean plain text, then confirms that text is genuinely 7-bit ASCII.
What Is ANSI to ASCII Converter?
A stripper for ANSI SGR (Select Graphic Rendition) escape sequences, the ESC[<params>m codes used for terminal color and text styling, paired with this category's strict ASCII validation on what's left.
It's the inverse of ASCII to ANSI Converter: instead of adding color codes to plain text, it removes them to recover the plain text.
How ANSI to ASCII Converter Works
The input is scanned with a pattern matching ESC (0x1B) followed by [, any digits and semicolons, and a trailing m, the standard SGR sequence shape, and every match is removed.
The remaining text is then validated character-by-character against the 0-127 ASCII range using this category's shared strict-ASCII validator, so any leftover control bytes or non-ASCII content are caught and reported.
When To Use ANSI to ASCII Converter
Use it to clean up text copied from a terminal, CI log, or ANSI-colored CLI output before pasting it somewhere that would otherwise show raw escape codes.
It's also useful for verifying that colored terminal output, once the styling is stripped, actually is plain 7-bit ASCII underneath.
Often used alongside ASCII to ANSI Converter and HTML Entities to ASCII Converter.
Features
Advantages
- Removes the specific SGR color/style escape pattern cleanly, leaving all other characters untouched.
- Confirms the stripped result is genuinely 7-bit ASCII, catching any other stray control bytes.
- A quick, purpose-built alternative to writing a one-off regex to strip color codes yourself.
Limitations
- Only strips SGR (color/style) sequences; other ANSI escape types (cursor movement, screen clearing) aren't recognized or removed.
- If stripped text still contains a non-ASCII or stray control character, the result is rejected rather than partially cleaned.
Examples
Best Practices & Notes
Best Practices
- If output still looks odd after stripping, check for a non-SGR escape type (like cursor movement) this tool doesn't target.
- Pair with ASCII to ANSI Converter to confirm you can rebuild an equivalent colored string from the stripped plain text.
Developer Notes
Stripping uses the pattern /\x1b\[[0-9;]*m/g, matching the real ESC (0x1B) control byte followed by [, any digits/semicolons, and a trailing m; the result is then passed through the category's shared validateStrictAscii helper.
ANSI to ASCII Converter Use Cases
- Cleaning up terminal or CI log output copied with embedded color codes before sharing or storing it as plain text
- Verifying that colored CLI output is ASCII-safe underneath its styling
- Producing test fixtures for code that needs to strip ANSI codes from log lines
Common Mistakes
- Expecting non-color escape sequences (cursor movement, clearing) to be stripped too; only the SGR color/style form is targeted.
- Assuming a rejection after stripping means the tool is broken, when it usually means an unrecognized escape type or genuinely non-ASCII character remains.
Tips
- If a rejection points at a code point around 27 (0x1B), that's a leftover ESC byte from an escape sequence this tool didn't recognize as SGR.
- Round-trip through ASCII to ANSI Converter to sanity-check that the stripped text reads correctly.