JSON Escape & Unescape

Turn text into a safe JSON string, or recover the text inside one.

Text or literal
Result

About this tool

Escape plain text into a JSON string literal, or unescape a literal back into text. The full escape set is handled: \" \\ \n \r \t \b \f and \uXXXX — in both directions, with surrogate pairs decoded correctly.

Two modes, because broken input arrives in two shapes: a complete literal (starts and ends with a quote) unescapes exactly; a fragment — text pasted from a log or a database cell with stray \n sequences — gets a mode that decodes the escapes without demanding the quotes.

Nothing is uploaded. The strings people escape are usually the sensitive kind — tokens, query fragments, file paths — which is exactly why this runs in the tab.

How to use it

  1. Paste your text into the input pane.
  2. Pick the direction: Escape wraps it as a JSON literal, Unescape unwraps one, Unescape fragment decodes escapes without requiring quotes.
  3. Copy the result. Characters that cannot appear in a literal are escaped the way JSON.stringify does it — no custom dialects.

Worked example

The sample escapes to a single-line literal with an escaped newline where the line break was, an escaped inner quote, and an escaped tab — and unescapes back to the exact original text.

One string, both directions

Frequently asked questions

Which characters get escaped?
Exactly the set JSON requires: quote, backslash, and the control characters (newline, carriage return, tab, backspace, form feed), plus anything below U+0020 as \uXXXX. Nothing else — forward slashes and non-ASCII text stay readable, because JSON allows them.
What is the fragment mode for?
Text like a\tb pasted from a log — escapes present, surrounding quotes absent. The strict unescape would refuse it; fragment mode decodes every valid escape sequence and reports any backslash that did not form one.
Why does my emoji survive unescaping?
An emoji is stored as two \uXXXX escapes (a surrogate pair) in some producers. Both halves are decoded together into the single character they represent, not into two broken halves.
Does it escape HTML or XML?
No — JSON escaping only. Escaping for HTML is a different job with a different character set; mixing the two is how double-escaping bugs happen.
Is my text uploaded anywhere?
No. The tool runs entirely in your browser; nothing you paste leaves the tab.