Skip to content

JSON Escape / Unescape

Turn text into a valid JSON string literal and back, or stringify a whole JSON document so it can live inside another JSON field or a code string. Four buttons, no uploads, no double-escaping guesswork.

Loading editor...
Paste text or an escaped string
Loading editor...
Result
Ctrl+Enter Escape

How to escape or unescape

The input panel accepts plain text or an escaped JSON string. Nothing runs until you click one of the four buttons.

  1. Paste text and click Escape. Quotes, backslashes, newlines, tabs, and other control characters are escaped and the result is wrapped in double quotes, ready to drop into a JSON document or a string literal in code.
  2. Paste an escaped string and click Unescape to get the original text back. Surrounding quotes are optional.
  3. Paste a whole JSON document and click Stringify JSON to turn it into one escaped string, for example to store JSON inside a JSON field, a config value, or a database column.
  4. Paste a string that contains escaped JSON (the usual symptom is {\"key\":...}) and click Parse string to get it back as pretty-printed JSON.

Click Copy or Download .txt when you are done.

Examples

Escape turns the sample text

She said "ship it" on
C:\Users\maya\reports
Tab:	here

into

"She said \"ship it\" on\nC:\\Users\\maya\\reports\nTab:\there"

Stringify JSON turns {"name": "Maya", "tags": ["a", "b"]} into

"{\"name\":\"Maya\",\"tags\":[\"a\",\"b\"]}"

and Parse string turns that line back into formatted JSON.

Double escaping and how to avoid it

If a string arrives as "{\\\"name\\\":...}" with doubled backslashes, it was escaped twice: once when the document was stringified and again when that string was put inside another JSON document, which is exactly what happens with a JSON payload stored in a JSON log field. One Unescape removes one layer; run it once per layer, then Parse string. Going the other way, use Stringify JSON once on the document, and do not click Escape on the already-escaped result unless you really want a second layer. The full list of escape sequences is in JSON escape characters.

Limits and notes

  • Input up to 5 MB. Everything runs as JavaScript in your browser; nothing is uploaded.
  • Escape follows the same rules as JSON.stringify: non-ASCII characters such as é or emoji stay as they are rather than becoming \uXXXX. Both forms are valid JSON, so other tools may show them differently.
  • Unescape and Parse string stop with a readable error if the input is not a valid JSON string, for example when it contains a raw newline or a lone backslash.
  • Stringify JSON needs valid JSON and minifies the document before escaping it. Objects that cannot be serialised at all are covered in JSON.stringify and circular references.
  • To do the same in code rather than by hand, see working with JSON in JavaScript. To repair input that is not quite JSON, use Fix JSON first.

Frequently Asked Questions

Which characters get escaped?
Double quotes, backslashes, and control characters: newline becomes \n, tab becomes \t, carriage return becomes \r, and other control characters become \uXXXX. Non-ASCII text such as accents or emoji is kept as-is, which is valid JSON.
What is the difference between Escape and Stringify JSON?
Escape treats the input as plain text and wraps it in quotes. Stringify JSON first parses the input as a JSON document, minifies it, then escapes the result, so you get one string literal that holds the whole document.
Why does my string have doubled backslashes like \\"?
It was escaped twice, usually once when the JSON was stringified and again when that string was placed inside another JSON document. Click Unescape once per layer, then Parse string to get the document back.
Unescape says the input is not a valid escaped string. Why?
The text must follow JSON string rules: no raw newlines, no lone backslashes, and quotes inside must be escaped. Surrounding quotes are optional. If the input is plain text, you want Escape instead.
Is my text uploaded?
No. Every button runs as JavaScript in your browser tab, so the text never leaves your machine.

Guides that go with this tool

More JSON tools

JSON Viewer (Tree View)

Explore any JSON document as a collapsible tree in your browser. Click a key to copy its JSONPath, click a value to copy it, and page through large arrays without freezing the tab.

JSON Fixer: Repair Invalid JSON

Repair broken JSON in your browser. Strips markdown fences and prose, fixes trailing commas, single quotes, comments, unquoted keys, Python literals and unclosed brackets, and lists every problem it detected.

JSON to CSV Converter

Convert a JSON array of objects to CSV in your browser. Nested objects are flattened to dotted columns, values are quoted correctly, and Excel-friendly output is one click away.

CSV to JSON Converter

Convert CSV with a header row into a JSON array of objects in your browser. Numbers and booleans are detected, leading-zero codes stay strings, and the delimiter is picked up automatically.

JSON to YAML Converter

Convert JSON to clean YAML in your browser with 2, 3 or 4 space indentation. Strings that a YAML parser would read as numbers, booleans or dates are quoted so they survive the round trip.

YAML to JSON Converter

Convert YAML to JSON in your browser. Multi-document files become an array, anchors and aliases are resolved, and only null, true, false and plain numbers are typed, so yes, NO and dates stay strings.

JSON to XML Converter

Convert JSON to XML in your browser. Choose the root and array item element names, nulls become xsi:nil, keys are sanitised into valid XML names, and text is escaped.

XML to JSON Converter

Convert XML to JSON in your browser. Attributes are kept as @_name keys, repeated tags become arrays, numbers and booleans are detected, and invalid XML reports the line and column.

JSON Compare (Diff)

Compare two JSON documents in your browser and get a structural diff that lists every changed, added, and removed value with its JSONPath. Key order and whitespace are ignored.

JSONPath Query Tester

Test JSONPath expressions against your JSON in the browser. Pick an expression, see the matches as a JSON array with a count, and explore the results in tree view.