JSON Stringify Online

Run JSON.stringify without opening a console: serialize JSON to one compact line or indented text, turn it into an escaped string you can paste into code, or parse a stringified value back into JSON. Runs in your browser.

What you can do here

Links for each operation: ?mode=compact, ?mode=pretty, ?mode=string and ?mode=parse.

Stringify, serialize and “to string” compared

OperationEquivalent codeOutput for {"a": "x y"}
Stringify (compact)JSON.stringify(v){"a":"x y"}
Serialize (indented)JSON.stringify(v, null, 2){ /   "a": "x y" / }
JSON to stringJSON.stringify(JSON.stringify(v))"{\"a\":\"x y\"}"
Parse string to JSONJSON.parse(JSON.parse(s)){"a":"x y"}

Stringifying parses the input first, so invalid JSON — a trailing comma, single-quoted keys, a missing comma — is rejected with the parser's error rather than passed through. Only whitespace between tokens changes; key order, array order, numbers and string contents are kept exactly (unless you tick Sort keys).

Worked example

Input:
{
  "name": "Ada",
  "roles": ["admin", "user"],
  "active": true
}

Stringify:      {"name":"Ada","roles":["admin","user"],"active":true}
JSON to string: "{\"name\":\"Ada\",\"roles\":[\"admin\",\"user\"],\"active\":true}"

When you need each one

Common questions

Is this the same as JSON.stringify in JavaScript?

Yes. The input is read with JSON.parse and written with JSON.stringify, with no spacer for compact output or 2, 4 or a tab for indented output.

How is JSON stringify different from JSON minify?

For valid JSON the compact output is identical: both produce the shortest legal form of the same data. The JSON minifier adds size and gzip statistics.

How do I convert JSON to a string?

Choose JSON to string. The JSON is compacted, every " and backslash is escaped, and the result is wrapped in quotes: "{\"a\":1}". Pick single quotes for JavaScript or SQL code that uses them.

How do I turn a stringified JSON string back into JSON?

Choose Parse string to JSON and paste the quoted value. It is unwrapped until it is real JSON (double-stringified values are handled too) and shown indented.

Does it reorder keys or change values?

No, unless you tick Sort keys. Very large integers beyond 253 lose precision, exactly as they do in JSON.parse.

Is my JSON uploaded?

No. Parsing and stringifying run in your browser; nothing leaves the page.