AbraCalc

Backslash Escape / Unescape

Escape or unescape backslash sequences (\n, \t, \r, \", \\) in any string. Runs entirely in your browser.

Pure browser JavaScript — no external libraries.

Embed this tool on your site
Cite this tool

APA

AbraCalc. (2026). Backslash Escape / Unescape [Online calculator]. Retrieved from https://abracalc.com/app/backslash-escape/

BibTeX

@misc{abracalc-backslash-escape, author = {AbraCalc}, title = {Backslash Escape / Unescape}, year = {2026}, howpublished = {\url{https://abracalc.com/app/backslash-escape/}} }

Did this tool answer your question?

How to use this tool

  1. Paste text into the input.
  2. Click Escape to convert special characters to \n, \t, etc.
  3. Click Unescape to convert sequences back to real characters.

Escape or unescape backslash sequences (\n, \t, \r, \", \\) in any string. Runs entirely in your browser.

How it works

The Backslash Escape / Unescape tool converts between human-readable escape sequences and the literal characters they represent. Common sequences include \n (newline), \t (tab), \r (carriage return), \" (double quote), and \\ (backslash itself).

Choose Escape to turn a string containing real newlines and tabs into a single-line representation where those characters are replaced by their backslash codes. Choose Unescape to do the reverse: convert a string that contains literal backslash sequences into the actual characters they stand for.

This is useful when copying strings into source code, JSON payloads, or configuration files that require escape sequences, or when a log file or API response contains escaped text that you want to read in its expanded form.

The tool processes only the five most common C-style sequences. It does not interpret octal, hex, or Unicode escape forms such as \x41 or \u0041 unless stated otherwise.

Worked examples

Escape a multi-line message for a JSON string value

  1. Type or paste a multi-line message into the input box (press Enter between lines as usual).
  2. Select the Escape mode.
  3. Click Convert.
  4. Copy the output -- newlines are now \n and tabs are \t.
  5. Paste the result directly into a JSON string without breaking the format.

A clean single-line escaped string ready to drop into a JSON property or source-code constant.

Read an escaped error message from a log

  1. Copy the escaped text from your log (e.g., Line 1\nLine 2\tindented).
  2. Paste it into the input.
  3. Select Unescape mode and click Convert.
  4. The output shows the message with real line breaks and indentation.

The error message is now readable in its original multi-line form.

Common mistakes to avoid

  • Running Escape on text that is already escaped, which double-escapes every backslash (e.g., \n becomes \\n).
  • Forgetting that a raw backslash must itself be escaped as \\ -- a lone backslash in the input is often mishandled by other tools downstream.
  • Expecting the tool to handle \uXXXX or \xXX Unicode/hex escapes, which it does not process.

Key terms

Escape sequence
A two-character combination starting with a backslash that represents a single special character, such as \n for a newline.
Unescape
The process of replacing backslash sequences in a string with the actual characters they encode.
Literal backslash
A single backslash character that is not part of an escape sequence; represented as \\ in escaped form.

Frequently asked questions

What sequences are handled?
\n (newline), \r (carriage return), \t (tab), \b (backspace), \f (form feed), \" (double quote), \' (single quote), \\ (backslash).

References & sources