Backslash Escaper & Unescaper

Escape special characters with C-style backslash sequences

Ad placeholder (leaderboard)

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 and binary bytes safely inside source code, configuration files and shell scripts.

How it works

Escaping walks through your text one character at a time. Well-known control characters map to short sequences: newline becomes \n, tab becomes \t, carriage return becomes \r, and the null byte becomes \0. Vertical tab, form feed and backspace become \v, \f and \b. The backslash itself doubles to \\, and quotes are escaped so the result is safe inside string literals. Any remaining non-printable byte (code point below 32, or DEL at 0x7f) is written as a two-digit hex escape \xHH.

Unescaping reverses the rule. The parser scans for a backslash, reads the following character, and emits the matching control character. It also understands \xHH (two hex digits) and \uXXXX (four hex digits). If a sequence is incomplete or unrecognised, the characters are kept literally so your data is never silently dropped.

Example

The two-line string with a tab between the words becomes:

Hello\tworld\nLine 2

Unescaping that exact text restores the original tab and newline. This round-trip is lossless for the supported sequences, which makes it safe to copy escaped text into a .c, .java or .json-adjacent file and decode it later.

Tips

  • Use escaping before pasting log lines or sample data into a string literal so editors do not break on the embedded newlines.
  • When unescaping, double-check sequences like \xZZ that are not valid hex — they are passed through unchanged rather than guessed.
  • This tool is case-insensitive for hex digits, so \x0A and \x0a both decode to a newline.
Ad placeholder (rectangle)