JSON Escape & Unescape
Turn text into a safe JSON string, or recover the text inside one.
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
- Paste your text into the input pane.
- Pick the direction: Escape wraps it as a JSON literal, Unescape unwraps one, Unescape fragment decodes escapes without requiring quotes.
- 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?
What is the fragment mode for?
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.