NV ToolkitFormat · Validate · Convert

JSON Tools

JSON Stringify Online

The exact behavior of JavaScript's JSON.stringify() — compact by default, the space argument, and what the serializer silently drops — plus a mode that reverses it.

In short

Run JSON.stringify online: compact or with the space argument, see what the serializer drops or converts, and unstringify an escaped string back to JSON. Free.

By NaveenKumar T · Updated

Learn: What is JSON? A Practical Introduction

  • Compact (default) or space = 2 / 4 / tab
  • Parse mode: unstringify back to JSON
  • Optional \uXXXX for non-ASCII

Runs entirely in your browser — nothing you paste or open here is uploaded, logged, or stored.How we handle data →

Example

JSON Stringify Online: input and output

A webhook payload with a nested object and an already-ISO timestamp string — stringified compactly, the true JSON.stringify(value) default this page starts from.

Input · json
{"event":"payment.succeeded","id":"evt_7Qa2","created":"2026-09-18T09:30:00Z","data":{"payment_id":"pay_88213","amount":4999,"currency":"usd","customer":"cus_5F0a"}}
Output · json
"{\"event\":\"payment.succeeded\",\"id\":\"evt_7Qa2\",\"created\":\"2026-09-18T09:30:00Z\",\"data\":{\"payment_id\":\"pay_88213\",\"amount\":4999,\"currency\":\"usd\",\"customer\":\"cus_5F0a\"}}"

The whole payload became one quoted line with every structural quote escaped as \" — no extra whitespace anywhere, because space is 0 by default — while the already-ISO created timestamp is just a string to the serializer and passes through completely unchanged inside the escaped text.

Learn more

What JSON.stringify actually does

JSON.stringify() is a real function with a specified, sometimes-surprising set of rules for what it keeps, converts, and drops — this page runs the actual serializer (not an approximation) so the output matches what your own JavaScript code would produce for the same input and arguments.

What JSON.stringify does to each JavaScript value
ValueResult
string, number, booleanSerialized as its JSON equivalent
nullnull
undefined (object value)Key omitted entirely
undefined (array element)Becomes null; array length is kept
Function, SymbolOmitted (object value) or null (array element), same as undefined
NaN, Infinity, -Infinitynull — JSON has no representation for any of them
Date instanceIts toJSON() result — an ISO 8601 string
BigIntThrows a TypeError
Circular referenceThrows a TypeError

The three arguments: value, replacer, space

JSON.stringify takes up to three arguments, and this page's controls map directly onto the second and third. The replacer — an array of key names to keep, or a function called for every key/value pair that can transform or drop it — is the most powerful and least often needed of the three; this page focuses on space, which is what most real usage actually varies, and Unicode handling, which the raw function doesn't offer a built-in switch for at all (it's implemented here as a post-processing pass over the already-valid JSON text).

javascript
// A replacer ARRAY keeps only the named keys, in that order:
JSON.stringify(order, ["id", "total"]);

// A replacer FUNCTION runs for every key, including the root ("" key):
JSON.stringify(order, (key, value) =>
  key === "internalNotes" ? undefined : value
);

// The third argument is what this page's Space option controls:
JSON.stringify(order, null, 2);   // 2-space indent
JSON.stringify(order, null, "\t"); // tab indent
JSON.stringify(order);            // this page's default — compact, no 3rd arg

Un-stringify: getting the JSON back

Unstringify mode reverses a single layer of JSON.stringify: it treats the input as a JSON string value (with or without its surrounding quotes), decodes the backslash escapes, and if what remains parses as JSON, pretty-prints that too — reporting the key count so you can sanity-check you got the right layer back. This is the same operation as this site's dedicated String to JSON converter, offered here as well because it's the natural complement to Stringify mode on the same page: stringify something, then immediately verify the round trip without switching tools.

Stringify vs JSON to String vs JSON Escape — three pages, three jobs

All three convert a JSON document into some form of string, and picking wrong just means an extra click, not broken output — but knowing the distinction saves that click. This page models the JavaScript JSON.stringify() function's own behavior specifically: its compact-by-default output, its space argument, what it silently drops, and an unstringify mode. JSON to String is language-general: a complete, delimited string LITERAL for Python, Java, C#, Go, SQL or PowerShell as well as JavaScript, always including the opening and closing quote marks. JSON Escape is the narrowest: just the escaped body, no delimiters, no language-specific quoting rules, for dropping into a string you already have. JSON Minify is a different job entirely — it keeps the result as JSON (not a string), just with insignificant whitespace removed.

Help

Frequently asked questions

Everything you need to know about the JSON Stringify Online.

01What does JSON.stringify actually do to my values?

It's a real serializer with real, sometimes-surprising rules, and this page shows the values it drops as well as the ones it converts. undefined values, functions and Symbols disappear entirely — an object key holding any of them is simply omitted from the output, and an array holding one becomes null in that slot instead of being removed (arrays keep their length). A Date instance calls its own toJSON() method, which returns an ISO string. NaN and Infinity have no JSON representation and both become the literal null. A BigInt throws a TypeError — JSON.stringify refuses to serialize one rather than silently rounding it. A circular reference (an object that contains itself, directly or through a chain) also throws, with a "Converting circular structure to JSON" message. Key order is preserved exactly as insertion order, and this page reproduces every one of these behaviors rather than approximating them.

02What is the space argument and why is 0 the default here?

It's JSON.stringify()'s third parameter, and it controls indentation: omitted or 0 (the default on this page) produces the tightest possible output with no extra whitespace anywhere — which is what JSON.stringify(value) actually does when you call it with no third argument, the single most common call shape in real code. A number from 1–10 inserts that many spaces per nesting level; the string "\t" (this page's Tab option) inserts a literal tab per level instead. This page defaults to compact specifically because that's the true default of the function it's modeling — a page that pretty-printed first would be showing you JSON.stringify(value, null, 2)'s output while claiming to demonstrate JSON.stringify(value), which is a different call.

03How do I reverse it (unstringify)?

Switch Mode to Unstringify and paste the stringified value — either the full quoted-and-escaped string JSON.stringify produced (with its outer quotes) or just the escaped content without them, both are accepted. The page parses one layer of escaping and, if what's left is itself valid JSON, parses and pretty-prints that too, reporting how many top-level keys it found; if the unescaped content isn't JSON, you get the plain unescaped text back instead. A value that was stringified twice (nested inside another JSON.stringify call) needs two passes — run Unstringify, then run it again on the result to peel the second layer.

04Why is my output double-escaped?

Because you stringified a value that was ALREADY a JSON string, so the serializer escaped the escapes: a document that was already text like "{\"a\":1}" gets its own backslashes doubled and its quotes escaped again on a second pass, producing \"{\\\"a\\\":1}\". This is a genuinely common accident — logging a payload with JSON.stringify(JSON.stringify(x)) instead of JSON.stringify(x), or a webhook provider that stringifies its body twice before sending it. Run the result through Unstringify twice (once per accidental layer) to get back to the real document, or check the code path that produced the value for a duplicate stringify call.

05How is this different from JSON to String and JSON Escape?

Three pages model three different things, and this is the one that models the JavaScript FUNCTION itself: what JSON.stringify(value, replacer, space) actually returns for a given value, including the parts it drops (undefined, functions) and the parts it converts (Date, NaN), plus the reverse operation. [JSON to String](/json-to-string) is the page for a complete, ready-to-paste string LITERAL in a language of your choice — Python, Java, C#, SQL and more, not just JavaScript, and always including the delimiters. [JSON Escape](/json-escape) is the narrowest of the three: it returns only the escaped BODY of a string, no delimiters, no JavaScript-specific semantics, for when you already have your own quotes to drop it into. If the question is "what would JSON.stringify(x) actually return," this page. If it's "give me a Python/Java/SQL string literal," JSON to String. If it's "just escape this text for inside a string I already have," JSON Escape.

Keep working

Related tools

Learn the format

Related guides

All guides →