JSON Escape / Unescape
100% private — runs on your device, never uploaded. Works offline once loaded.
Turn raw text into a properly escaped JSON string literal, or reverse it to get the original text back. Quotes, backslashes, newlines, and tabs are all handled correctly, locally in your browser.
What escaping a JSON string means
JSON string values live inside double quotes, so any character that would break out of or confuse that literal has to be written with a backslash escape. Escaping takes raw text — which might contain double quotes, backslashes, tab characters, or line breaks — and rewrites those characters as \", \\, \t, and \n so the whole thing becomes a single valid JSON string. Unescaping reverses that: it reads the escape sequences and gives you back the original raw text, newlines and all.
How this tool does it safely
Rather than hand-rolling replacements that miss edge cases, the escaper uses the browser's built-in JSON.stringify, which is guaranteed to produce a spec-correct string literal — including escapes for control characters you can't see. The unescaper uses JSON.parse, so it accepts exactly what a real JSON parser would and rejects malformed input with a clear error. Because both directions rely on the same engine your code will use, what you copy here behaves identically at runtime.
When you need it
The most common case is embedding text inside a JSON payload by hand — a log message, an HTML snippet, a SQL query, or a multi-line template — where stray quotes and newlines would otherwise produce invalid JSON. Unescaping is just as useful in reverse: when you copy a string value out of a raw JSON response or a log line and want to read the real newlines and quotes instead of the escaped soup.
- Pasting a code snippet into a JSON config value
- Building an API request body in a text editor by hand
- Reading an escaped error message pulled from server logs
- Preparing a string for a JSON-based test fixture
Escape sequences you'll see
Standard JSON recognises \" (double quote), \\ (backslash), \/ (forward slash, optional), \b, \f, \n, \r, \t, and \uXXXX for any other character by its code point. Single quotes and most printable characters do not need escaping, which is why the escaped output usually looks close to your original text apart from the special characters.
Frequently asked questions
What's the difference between escaping and encoding like Base64?
Escaping keeps the text human-readable and only rewrites characters that break a JSON string. Base64 transforms bytes into an opaque ASCII blob. They solve different problems.
Why does my unescape fail?
The input isn't a valid JSON string literal — usually a stray unescaped backslash or quote. Check that every backslash is part of a real escape sequence.
Does escaping change my visible text?
It only changes how special characters are written. The meaning is identical — an unescape brings back exactly what you started with.
Can I escape multi-line text?
Yes. Line breaks are converted to \n so the whole block becomes a single valid JSON string on one line.
Are Unicode characters escaped?
By default JSON.stringify keeps most Unicode as-is; only control characters and required specials are backslash-escaped. The output stays valid either way.
Should I include the surrounding quotes?
Turn on the wrap option when you want a complete, ready-to-paste string literal; leave it off when you're pasting into an existing pair of quotes.
Advertisement