JSON Stringify Online

JSON.stringify & JSON.parse
online — free & instant

Paste a JavaScript object and see the serialized JSON string, or paste a JSON string to parse it into a formatted object. Escape, unescape, and pretty-print — all in your browser.

Open JSON Stringify Tool

Stringify, parse, and escape in seconds

Paste your data Drop a JavaScript-like object, a JSON string, or an escaped JSON string into the input area.
Instant serialization The tool formats your input as pretty-printed JSON (like JSON.stringify with spacing) or compact minified output.
Escape & unescape See how special characters are escaped — quotes, backslashes, newlines, and Unicode are all handled correctly.
Copy or download One-click copy or download the result. Share a link with the JSON embedded in the URL for quick collaboration.

No account. No upload. No nonsense.

🔒

Fully Private

Your data never leaves your device. All stringify and parse operations run in JavaScript, in your browser.

🛠️

Developer Friendly

Behaves like the browser console — JSON.stringify with configurable indentation, plus syntax highlighting.

Instant Results

No server round-trips. Formatting, minification, and parsing happen as you type.

Related JSON tools

JSON Formatter Pretty-print JSON with syntax highlighting and a collapsible tree view.
JSON Minifier Strip all whitespace and compress JSON to the smallest valid form.
JSON Validator Validate your JSON and get clear error messages with line numbers for quick fixes.
JSON Repair Fix broken JSON — trailing commas, unquoted keys, single quotes, and Python literals.

Common questions answered

What does JSON.stringify do?

JSON.stringify converts a JavaScript value (object, array, string, number, boolean, or null) into a JSON-formatted string. It serializes the data so it can be stored, transmitted over a network, or saved to a file.

What is the difference between JSON.stringify and JSON.parse?

JSON.stringify converts a JavaScript object into a JSON string (serialization). JSON.parse does the reverse — it takes a JSON string and converts it back into a JavaScript object (deserialization). They are inverse operations.

How do I escape special characters in JSON strings?

JSON.stringify automatically escapes special characters: double quotes become \" , backslashes become \\, newlines become \n, tabs become \t, and control characters are escaped as \uXXXX sequences. This tool shows you the escaped output instantly.

Is this JSON stringify tool free?

Yes, completely free with no account or signup required. All processing runs in your browser — no data is sent to any server.

Can I pretty-print the stringified JSON output?

Yes. The formatter supports custom indentation (2 spaces, 4 spaces, or tabs). You can also minify the output to a single compact line for production use.

What is JSON.stringify?

JSON.stringify() is the built-in JavaScript function that converts a value into a JSON string. It is called every time an application sends data to an API, writes to localStorage, or serializes state. Understanding its behavior — how it handles undefined, functions, circular references, and the replacer parameter — is essential for debugging serialization issues.

This tool mirrors JSON.stringify() behavior with full control over output. You can choose indentation (the third parameter), apply a replacer to filter or transform values (the second parameter), and see exactly how JavaScript types map to JSON. This is useful for previewing what your API will actually send and catching issues like undefined values being silently dropped.

See how JavaScript types serialize
Input
{
  "name": "Alice",
  "callback": undefined,
  "date": new Date(),
  "regex": /test/g
}
Output
{
  "name": "Alice"
}

// undefined, functions, RegExp,
// and Symbol are omitted by
// JSON.stringify()

Get the most out of this tool

Ready to stringify your JSON?

Free forever. No signup. Works offline.

Open JSON Stringify Tool

JSON.stringify() and JSON serialization

JSON.stringify() is the JavaScript function that converts a JavaScript value (object, array, string, number, boolean, null) into a JSON-formatted string. It is the serialization half of JSON handling — the other half being JSON.parse() which deserializes. Stringification is necessary whenever you need to transmit JavaScript data over a network, store it in a string-based storage system, or embed it in text content like HTML.

The second parameter of JSON.stringify() is the replacer — either an array of key names to include, or a function that transforms values during serialization. An array replacer produces JSON with only the specified keys, functioning like a field projection. A function replacer can transform, exclude (by returning undefined), or coerce values during serialization — for example, converting Date objects to ISO 8601 strings, or converting BigInt values (which JSON.stringify cannot handle natively) to strings.

The third parameter is the space parameter, which adds indentation for readability. JSON.stringify(data, null, 2) produces 2-space indented JSON identical to this tool's format output. JSON.stringify(data, null, '\t') uses tabs. Without the space parameter, the output is minified with no whitespace. This is the built-in way to get pretty-printed JSON in JavaScript, though it is slower than a dedicated formatter for large inputs.

JavaScript values that cannot be represented in JSON are handled specially. undefined values are omitted from objects and replaced with null in arrays — since JSON has no undefined type. Function values are also omitted. Symbol values are omitted. Circular references throw a TypeError. NaN and Infinity become null (since JSON has no concept of these IEEE 754 special values). BigInt throws a TypeError by default — you must use a replacer to convert them to strings first.

JSON.parse(JSON.stringify(obj)) is a common pattern for creating a deep clone of a plain JSON-serializable JavaScript object. This works because JSON serialization strips all non-JSON types (functions, undefined, Symbols) and creates a completely new object graph from the parsed string. However, it is significantly slower than modern alternatives like structuredClone() (available in Node.js 17+ and modern browsers) and loses non-JSON values like Dates (which become strings) and Maps (which become empty objects).

Custom toJSON() methods allow objects to control their JSON serialization. If an object has a toJSON() method, JSON.stringify() calls it and serializes the return value instead of the object itself. This is how the built-in Date object serializes to an ISO 8601 string — Date implements toJSON(). Custom classes can implement toJSON() to produce a clean, intentional JSON representation that hides internal implementation details.

When developers use this tool

Converting objects to JSON strings for APIs Preview how a JavaScript object looks when stringified before sending it as a request body. See exactly what JSON the server receives, including which fields are serialized and which are omitted.
Debugging stringify behavior When JSON.stringify produces unexpected output — missing fields, null values where you expected a number, quotes where you expected a number — use this tool to isolate the problem and understand how the serialization transforms your data.
Preparing strings for localStorage localStorage only stores strings. Before storing a JavaScript object, stringify it. This tool shows you the stringified form and its byte length, helping you manage localStorage quota usage before hitting the 5MB limit.
Embedding data in HTML templates When server-side templates embed JSON data in HTML script tags for client hydration, stringify the data to produce the correct JSON string. This tool also shows you the escaped form safe for use inside HTML attribute values.

Additional frequently asked questions

What happens to undefined values when stringifying?

JSON has no undefined type. JSON.stringify handles undefined in three ways depending on context: in objects, a property with an undefined value is completely omitted from the output; in arrays, undefined is replaced with null; at the top level, JSON.stringify(undefined) returns the JavaScript value undefined (not a string), which is often unexpected.

Can I stringify a JavaScript Map or Set to JSON?

Not directly. Maps and Sets are not JSON-serializable by default — JSON.stringify(new Map([['a',1]])) produces "{}". To serialize a Map, convert it to an object first: Object.fromEntries(map). To serialize a Set, convert to an array: [...set]. Alternatively, provide a replacer function that handles Map and Set types specially.

Is JSON.stringify the same as JSON serialization in other languages?

The concept is the same — converting a native data structure to a JSON string — but the behavior differs. Python's json.dumps() preserves more type information (Python Decimal becomes a number, not a string). Java's Jackson handles POJOs with annotations. Go's json.Marshal follows struct tags. Each language has its own rules for handling non-JSON types, so cross-language behavior may differ.

How do I stringify a JavaScript object with circular references?

JSON.stringify throws TypeError for circular references because JSON cannot represent cycles. To handle circularity, use a replacer function that tracks seen objects and replaces circular references with a sentinel value (like "[Circular]"), or use a library like flatted or json-stringify-safe which handle cycles gracefully.