UTILS.
Private by default
\n

Backslash Escaper

Escape or unescape backslash sequences such as \n, \t and \uXXXX.

Your files stay on this device

Files are processed in your browser, never uploaded. The site downloads code and assets to run the tools. No accounts or trackers.

Use Download to save this tool as one HTML file for offline use.

Privacy →
output

About this tool

Convert real newlines and tabs to backslash sequences or expand them back, entirely in your browser.

Escaping replaces five characters with backslash sequences: a backslash becomes \\, a line break \n, a tab \t, a carriage return \r and a double quote \". Everything else, including accented letters, is left as typed, and the result is not wrapped in quotes.

Unescaping turns \n, \t, \r, \\, \" and four-digit \uXXXX sequences back into real characters. Any other sequence, such as \b or \x41, is passed through unchanged rather than reported as an error. Escape runs on load and when you press its button, so choose escape or unescape again after editing the text.

Frequently asked questions

Which sequences are supported?
Escaping handles backslash, newline, tab, carriage return and double quote; unescaping also expands \uXXXX code points.
Does it parse JSON?
No — it works directly on backslash sequences in plain text rather than full JSON values.
How is this different from the JSON Escape tool?
Backslash Escape handles only the five characters above. JSON Escape runs the text through JSON.stringify, so it also writes other control characters as JSON escapes, and its unescape step expects a valid JSON string and shows an error otherwise.

More tools