JSON Escape / Unescape
Backslash-escape text into a JSON string body — or unescape one back to text — entirely on this device.
Off keeps non-ASCII characters literal — still valid JSON; on escapes each one as \uXXXX (astral characters become a surrogate pair).
Press ? for shortcuts
Do it offline:$ jq -Rs . file.txt
How to use it
- Choose Escape to encode text or Unescape to decode a body; the detected badge reads your paste and preselects one, and the s key flips them.
- Since Escape wraps nothing around its result, drop the body straight into a JSON field, log value or config entry that already carries its own quotes.
- Switch on Escape non-ASCII when a destination rejects raw Unicode: each character above U+007F becomes a backslash-u escape, tallied by a chip.
- Send the result to the clipboard or a .txt file; a permalink is offered too, held behind a confirm whenever the paste looks like a secret.
JSON escaping rewrites text so it can live inside a JSON string: the double quote becomes backslash-quote, the backslash doubles, and every line break, tab or control turns into a short escape. What comes back is the body on its own — the characters that sit between the quotes, minus the quotes. Unescape reverses that, turning an escaped body back into plain text.
Examples
He said "hi"
line 2He said \"hi\"\nline 2The result has no wrapping quotes — it is the body you paste between quotes that already exist. Inner double quotes become backslash-quote; the line break becomes backslash-n, counted as one control.
café ☕caf\u00E9 \u2615With Escape non-ASCII on, é leaves as backslash-u00E9 and the beverage sign as backslash-u2615 — each its own code point in four hex digits. A chip reports two rewrites, and JSON.parse restores both.
Tab\tafterTab afterThe pasted body already holds a backslash-t, so Unescape reads it as one tab and prints a real tab between Tab and after. Escaping would fold that tab back into backslash-t.
emoji 😀emoji 😀An emoji sits above U+FFFF and is already legal inside a JSON string, so the default returns it as typed. With Escape non-ASCII on it turns into the surrogate pair \uD83D\uDE00 instead.
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
The body, never a finished token
Escaping hands back only what belongs between the quotes and adds none of its own. For a complete JSON string value, delimiters included, reach for JSON Stringify — it runs this very rewrite and then encloses the result.
Which characters change, and which never do
Five characters take short forms — backslash-b, backslash-t, backslash-n, backslash-f, backslash-r — and any other control below U+0020 becomes a four-digit backslash-u. The double quote and backslash are always escaped; a forward slash is accepted on input yet never emitted.
Unicode stays readable unless you ask otherwise
By default accented letters, symbols and emoji pass through untouched, keeping the JSON valid and legible. Turn on Escape non-ASCII and each unit above U+007F is spelled backslash-u; anything above U+FFFF, emoji included, becomes a two-unit surrogate pair.
Pasting a whole quoted string is allowed
Paste a body still wearing its outer quotes and Unescape removes the matching pair, noting it on a chip; stray surrounding whitespace is trimmed on another. A lone opening quote with no partner is reported, not guessed, and raw tabs or newlines inside the body are left alone.
One megabyte is the ceiling, and it refuses
Past the limit the page declines the whole paste rather than shortening it, so error positions count across all you gave. For a file of any size, jq -Rs . file.txt does the job — though it quotes the text, where this page returns the body alone.
Common errors
Input is larger than the 1 MB limit for this tool. For bigger payloads use the CLI: jq -Rs . file.txt- Beyond a megabyte the transform is declined outright: your paste is never silently trimmed, and no partial body comes back. The named command streams a file of any size into a JSON string on your own machine.
`\q` at position 9 is not a valid JSON escape- JSON allows a small, fixed set of escapes, and backslash-q is not among them. Counting starts at one from the front of your paste; a Windows path taken for an escaped body is the usual source.
`\u00` at position 9 is truncated — `\u` needs 4 hex digits- A backslash-u escape needs four hex digits and this one runs out early, leaving nothing whole to decode. Usually the copy was clipped mid-sequence; paste the complete value instead of trimming it.
FAQ
What is the difference between JSON escape and JSON stringify?
Escape returns the body by itself — the encoded characters with no quotes around them. JSON Stringify runs the very same encoding, then puts the quotes on for a whole JSON string value. Choose escaping when the quotes already exist at the destination.
Why did my emoji come through unescaped?
By default any character already legal in a JSON string is left as it is, and emoji qualify, so they read back just as typed. For ASCII-only output, switch on Escape non-ASCII and each becomes a backslash-u surrogate pair.
Does this match JavaScript's JSON.stringify()?
For the body it does: call JSON.stringify on your text, drop the first and last quote, and you have the characters this page produces. The one divergence is an unpaired surrogate, replaced with U+FFFD and flagged so the output stays well-formed.
How is this different from the String Escaper tool?
The String Escaper spans several language syntaxes and can wrap output in each language's own quotes. This page does one job — JSON string bodies, with no language menu and no surrounding quotes.
Keyboard shortcuts
- ⌘/Ctrl + Enter
- Run the active direction again, at any input size.
- ⌘/Ctrl + S
- Save the result as a .txt download, overriding the browser save.
- ⌘/Ctrl + C
- Copy the full result, or just a selection when one exists.
- ⌘/Ctrl + Shift + C
- Copy the full result even with a selection active.
- s
- Swap escape and unescape (guarded in fields, during IME, under the single-key kill switch).
- t
- Advance to the next theme; the single-key guards apply.
- ? or ⌘/Ctrl + /
- Open the shortcut overlay, browser conflicts named.
- Esc
- Dismiss the topmost overlay; the input stays.