The backslash escaper and unescaper converts hard-to-see control characters into printable C-style escape sequences, and turns those sequences back into the raw characters they represent. It is the everyday tool for embedding multi-line text, tabs, binary bytes, and Unicode codepoints safely inside source code, configuration files, SQL strings, and shell scripts.
How it works
Escaping (raw text → escape sequences)
The escaper walks through your text one character at a time and converts each special character to its backslash sequence:
| Raw character | Code point | Escaped |
|---|---|---|
| Null byte | 0x00 | \0 |
| Backspace | 0x08 | \b |
| Tab | 0x09 | \t |
| Newline (LF) | 0x0A | \n |
| Form feed | 0x0C | \f |
| Carriage return (CR) | 0x0D | \r |
| Vertical tab | 0x0B | \v |
| Backslash | 0x5C | \\ |
| Single quote | 0x27 | \' |
| Double quote | 0x22 | \" |
| DEL | 0x7F | \x7F |
| Other non-printable | < 0x20 | \xHH |
Any other non-printable byte (code point below 32 or DEL at 0x7f) that does not have a named sequence is written as a two-digit hex escape \xHH.
Unescaping (escape sequences → raw characters)
The unescaper scans for a backslash, reads the following character(s), and emits the matching raw byte. It handles:
- Single-letter sequences:
\n,\t,\r,\0,\v,\f,\b,\\,\',\" - Two-digit hex:
\xHH(for example\x1Bfor ESC) - Four-digit Unicode:
\uXXXX(for exampleéfor é)
If a sequence is incomplete or unrecognised, the characters are kept literally so your data is never silently dropped or corrupted.
Worked example
The two-line string with a tab separator:
Hello\tworld\nLine 2
Pasting that exact text into the unescape field restores the original tab between “Hello” and “world” and the newline at “Line 2”. Round-tripping is lossless for all supported sequences.
When to use this vs other encoders
| Escaping method | Use case | Tool |
|---|---|---|
| C-style backslash | C, C++, Java, C#, shell strings, many config formats | This tool |
| JSON string escaping | JSON values (stricter subset of C-style) | JSON encoder |
| URL / percent encoding | Query strings, path segments | URL encoder |
| HTML entity encoding | HTML text, attribute values | HTML escaper |
| Base64 | Binary data safe for text transport | Base64 encoder |
This tool produces C-style sequences recognised by C, C++, Java, Python, JavaScript, Go, Ruby and most configuration file parsers. It is not a JSON encoder (which has a stricter subset of the same sequences and no \xHH) and not a URL encoder (which uses %HH instead of \xHH).
Practical tips
- Paste log lines into string literals: escape before pasting so editors do not interpret embedded newlines as line breaks in the code.
- Hex escapes are case-insensitive here:
\x0Aand\x0aboth decode to a newline (LF). Most parsers are the same. - Invalid sequences pass through unchanged:
\qis not a valid sequence; it will appear literally as\qin the output rather than being silently dropped.