{ } JSON Workbench0 network requests. Check DevTools

"JSON Stringify":{ }

JSON stringify compacts a JSON value and wraps it in a single-quoted string literal, like '{"id":42}', ready to paste into JavaScript or Python source, a config, or a DB column. Messy input (single quotes, trailing commas) is auto-repaired first. 100% in-browser.

What is JSON stringify?

Stringify wraps a JSON value into an escaped string literal, a JSON string that contains your serialized JSON. It's the serialize-and-escape step so a value can be safely embedded where a string is required: inside another JSON payload, a database text column, a log line, or a source-code constant.

It mirrors JavaScript's JSON.stringify(value, replacer, space) followed by quoting the result. Parse / unescape is the inverse. Everything runs 100% in-browser with zero network requests.

Edge cases & gotchas

  • Output is a single-quoted literal wrapping compact JSON. Since JSON itself uses double quotes, the literal stays readable with no \" noise, and pastes cleanly into JS or Python source.
  • Apostrophes and backslashes inside string values are escaped (\', \\) so the literal reproduces the exact JSON text.
  • Single-quoted literals aren't valid JSON; they're for embedding in code. Need a JSON-legal escaped body instead? Use Escape.
  • Repair-aware parsing tolerates single quotes, trailing commas, and Python literals before serializing.
  • NaN, Infinity, -Infinity serialize to null (JS semantics); BigInt throws.
  • Dates aren't a JSON type. They serialize as ISO-8601 strings via toJSON() and don't round-trip back to Date automatically.

JSON.stringify argument & type reference

ArgTypePurpose
valueanyValue to serialize
replacerfunction | arrayTransform each entry, or whitelist property names
spacenumber | stringIndentation (≤10 spaces, or a string like "\t")
InputResult
undefined / function / Symbol (in object)omitted
undefined / function / Symbol (in array)null
NaN / Infinitynull
BigIntTypeError
DateISO string via toJSON()
Map / Set{}
circular referenceTypeError

How to use

  1. Paste or upload JSON. Repair-aware parsing tolerates minor syntax issues.
  2. The tool serializes and escapes the value into a string literal.
  3. Copy the output (wrapping quotes included) for embedding in source, JSON, or a database field.
  4. To reverse, use Unescape / parse to recover the original value.
  5. Verify zero network requests in DevTools → Network; everything runs client-side.

Examples

Basic object → string literal

Input
{"name":"John","age":30}
Output
'{"name":"John","age":30}'

Single-quoted input is repaired first (edge case)

Input
{'id': 42, 'tags': ['json', 'diff'], 'active': true}
Output
'{"id":42,"tags":["json","diff"],"active":true}'

Apostrophes & escapes inside values

Input
{"msg":"it's a line\nbreak"}
Output
'{"msg":"it\'s a line\\nbreak"}'

FAQ

What is the difference between stringify and escape?

Escape outputs only the escaped body (no wrapping quotes); stringify produces a full JSON string literal with surrounding quotes.

What does the JSON.stringify replacer argument do?

It's an optional 2nd arg: a function to transform each key/value, or an array of property names to whitelist. JSON.stringify(obj, ["week","month"]) keeps only those keys.

What is the space argument?

The optional 3rd arg controls indentation: a number (spaces, max 10) or a string like "\t". Purely for pretty-printing.

Why did my undefined / function / Symbol values disappear?

In JavaScript's JSON.stringify they aren't valid JSON: omitted inside objects, converted to null inside arrays. Symbol keys are always ignored.

Why do I get a "circular reference" error?

JSON.stringify throws a TypeError on objects that reference themselves. Remove the cycle, or use a replacer / structuredClone before serializing.

Why do I see double backslashes where I expected single?

You stringified twice (double-escaping). Unescape / parse once to undo it.

Related tools