How to use the JSON string escaper
- Paste or type your text into Text.
- Choose Mode: Escape turns raw text into JSON string content; Unescape does the reverse.
- In Escape mode, tick Wrap in double quotes if you want a complete string value, and Escape non-ASCII as \uXXXX if the target only accepts plain ASCII.
- Copy the result. In Unescape mode the output is the plain text, with real line breaks.
What it does and when to use it
Use Escape when you drop text into a JSON document by hand: an error message for a test fixture, a multi-line SQL query in a config file, a Windows path, or a prompt for an API request body. Unescaped, the first double quote or line break ends the string and the file stops parsing.
Use Unescape to read a log or API value that arrives as one long line full of \n and \".
To check that a whole document is valid after your edit, run it through the JSON validator or the JSON formatter. For JavaScript source strings (single quotes, \x escapes, template literals) the JS Unicode escaper is the better fit, and for other targets such as regex or CSV there is a general string escaper.
How it works
Escape mode passes your text to the browser’s own JSON.stringify and removes the outer quotes, so the result matches what any JavaScript program would write. That follows the string rules in section 7 of RFC 8259: quote, backslash and control characters must be escaped, and anything else may be. The ASCII option then replaces every character from U+007F upward with a lowercase \uXXXX code.
Unescape mode reads the text as the inside of a JSON string. Surrounding quotes are optional: without them, the tool adds quotes and escapes any bare double quotes. Real line breaks and tabs count as \n and \t. A strict parser then decodes it and names the first escape it does not accept.
Worked examples
Escape, with the default sample text (a quote, a newline, a backslash and a tab):
Input: She said "hi"
Path: C:\temp done
Output: She said \"hi\"\nPath: C:\\temp\tdone
Escape with Escape non-ASCII as \uXXXX ticked:
café ☕ 😀 → caf\u00e9 \u2615 \ud83d\ude00
Unescape of "Line one\nLine two \u2192 done" gives two lines of text, the second reading Line two → done. Unescape of it\'s fails with Invalid escape sequence \', because JSON has no single-quote escape.
Limits and tips
- In Unescape mode a real tab or line break in the input is kept as it is, as if it were written
\tor\n. - Escape mode does not touch
/. JSON allows\/but never requires it. - It works on one string value at a time, not on a whole document.
- Everything runs in your browser; the text is not sent anywhere.
Frequently asked questions
Which characters does Escape change?
Why does an emoji turn into two \u codes?
Why does Unescape reject \' or \x41?
Is the escaped text safe to put inside an HTML script tag?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.