JSON Stringify / Unstringify
Wrap a JSON document as a quoted, escaped JSON string token — and unstringify it back — entirely on this device.
Press ? for shortcuts
Do it offline:$ jq -Rs . file.txt
How to use it
- Paste a JSON document to wrap or a quoted token to unwrap; the badge reads the paste, preselects a direction, and switches with the Stringify and Unstringify tabs.
- Unstringify skips whitespace around the token and flags it on a chip; input that is not one complete literal stops on a message you can jump to.
- Copy the token, download it, or Share the state as a link — with a confirm step first whenever the input looks credential-shaped.
Stringify turns a whole JSON document into a single quoted string value: the surrounding double quotes are added and every inner quote, backslash and line break is escaped, so the result drops straight into another JSON field, a log line or an environment variable. Unstringify reverses that, peeling the quotes back off to recover the original text — and both directions run here on your own device.
How it works
RFC 8259 section 7 defines a JSON string as characters between two double quotes, where the quote, the backslash, and control characters below U+0020 must appear as an escape such as backslash-n. A JSON string token is that whole construct — the quotes plus the escaped body — the only place a JSON document may hold free-form text.
Wrapping a document as one such token is how a payload rides inside another — an API field, a structured log line, a one-line variable. The CLI equivalent is jq -Rs . file.txt, which reads a file as raw text and slurps it into a single JSON string; the inverse, jq -r . file.json, is Unstringify.
Examples
{"name":"O'Brien"}"{\"name\":\"O'Brien\"}"Stringify adds the outer quotes and escapes the inner ones; the apostrophe in O'Brien stays, since JSON escapes only the double quote. JSON.parse returns the original text.
"{\"a\":1}"{"a":1}The exact inverse: Unstringify strips the outer quotes and decodes the body, so each escaped quote turns plain and the token becomes its object again.
line one
line two"line one\nline two"A real line break becomes a single-line token — written as the two characters backslash-n — so a multi-line payload fits on one line.
"hi" hiSpaces around the token are ignored and noted on a chip; the recovered text is just hi. The quotes must stay — only whitespace is tolerated outside them.
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
The quotes set this apart from escaping
A raw escape rewrites the body and stops, leaving a fragment. This page adds the enclosing quotes too, so the output is a finished JSON string value — for the body alone, use the JSON Escape page.
Unstringify wants one token, nothing more
A bare object, number or true is declined: those are JSON values, not strings, so there is nothing to unwrap. The message points at the first character and suggests Stringify.
The round trip loses nothing
Both directions treat the payload as opaque text, so wrapping then unwrapping returns exactly what you began with — key order, spacing inside strings, and long integers intact, down to every digit of a 19-digit id.
Where the token leaves JSON.stringify
For ordinary text the result equals JavaScript's JSON.stringify byte for byte. The one deliberate difference: an unpaired surrogate becomes U+FFFD and is flagged, never a lone escape, so the token is always well-formed.
Common errors
a JSON string token must start with a double quote, but position 1 is `{` — to wrap this text as a JSON string, use Stringify- The Unstringify pane was given a JSON object, not a string. Switch to Stringify to wrap it, or confirm the token still has its surrounding quotes.
unexpected `b` at position 4 — a JSON string must be a single string token with nothing after the closing quote- The literal ended at its closing quote and then more characters followed — usually two tokens pasted together or a stray character. Only one value is accepted.
the JSON string literal opened at position 1 has no closing double quote- An opening quote was found but its close never arrived, usually a copy that was cut short. Restore the final quote to complete the token.
`\x` at position 2 is not a valid JSON escape- Inside the quotes a backslash must begin one of JSON's escapes — the quote, backslash, slash, b, f, n, r, t or backslash-u — and x begins none, so the body cannot be decoded.
Input is larger than the 1 MB limit for this tool. For bigger payloads use the CLI: jq -Rs . file.txt- A refusal, not a trim: the page transforms all of your input or none, and your paste stays put. At that size jq slurps the file into one JSON string on your machine.
FAQ
How is JSON stringify different from JSON escape?
Escaping rewrites the characters inside a string and returns that body on its own. Stringify performs the same rewrite and then wraps it in double quotes, so you get a complete JSON string value ready to drop into a document. The quotes are the difference.
Why would I wrap JSON inside a JSON string?
Whenever one payload must travel as a value inside another: a webhook body in a single field, a log event as one escaped line, or a one-line CI or container variable. The document is flattened into a quoted string first.
Is Unstringify the same as JSON.parse?
For a single string token the result matches JSON.parse exactly. Otherwise it differs: instead of a browser-specific parser error, Unstringify points at the character that breaks the one-literal rule, so the message stays stable.
Keyboard shortcuts
- ⌘/Ctrl + Enter
- Re-run the active tab now, at any input size.
- ⌘/Ctrl + S
- Save the result as .txt; the overlay notes it overrides the browser save.
- ⌘/Ctrl + C
- With nothing highlighted, copy the whole result; a highlighted span copies itself.
- ⌘/Ctrl + Shift + C
- Copy the whole result even when a selection is active.
- s
- Flip Stringify and Unstringify — off inside text fields, during IME composition, and while cancelling a run.
- t
- Step to the next theme (the single-key guards apply).
- ? or ⌘/Ctrl + /
- Open the shortcut help, which lists any browser conflicts.
- Esc
- Close the topmost overlay; your input stays.