JavaScript developers know JSON.stringify(obj, null, 2) as the standard way to pretty print an object, but when you already have a raw JSON string and just want to read it clearly, there is no need to open a console.
Loading JSON Formatter…
Browser equivalent of JSON.stringify(obj, null, 2)
Syntax highlighted output with correct types
Works for non-developers who cannot run JS
No console, no Node.js, no code needed
Drop the JSON Formatter into any page — blog post, product docs, intranet, school portal — with a single line of HTML. Your visitors get the full tool, processed entirely in their browser. No backend, no uploads, no signup.
Embed code
<iframe
src="https://www.fixtools.io/json/json-formatter?embed=1"
width="100%"
height="780"
frameborder="0"
style="border:0;border-radius:16px;max-width:900px;"
title="JSON Formatter by FixTools"
loading="lazy"
allow="clipboard-write"
></iframe>Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.
JSON.stringify() is JavaScript's built-in JSON serializer, defined in the ECMA-262 specification since ES5 in 2009. When called with a space argument, it produces human-readable indented output. JSON.stringify(obj, null, 2) produces 2-space indented JSON. JSON.stringify(obj, null, "\t") produces tab-indented JSON. The second argument is a replacer: null includes all enumerable own properties, an array of strings includes only those named properties, and a function is called for each key-value pair and can transform or exclude individual values. This flexibility makes JSON.stringify suitable for both full serialization and filtered output.
The core limitation of JSON.stringify as a formatting tool is that it requires a JavaScript data structure as input, not a JSON string. If you already have a serialized JSON string from an API response, a log file, or a config file, you need JSON.parse() first: JSON.stringify(JSON.parse(jsonString), null, 2). This two-step sequence requires either a browser console, a Node.js REPL, or a dedicated script. For developers who use the console daily this is fast. For non-developers, for people on restricted machines, or for anyone who simply wants a faster path, this is unnecessary friction.
FixTools wraps this two-step operation in a web interface accessible from any browser. The input accepts a raw JSON string. Under the hood, the tool calls JSON.parse() to validate and deserialize the input, then JSON.stringify() with the chosen indent to produce the formatted output. The browser engine provides syntax highlighting on the rendered result, distinguishing strings, numbers, booleans, null, keys, and structural characters by colour. The final output is equivalent to what you would get running the same commands in the browser console, with better readability and a one-click copy button.
JavaScript has several JSON quirks that catch developers off-guard. BigInt values are not serialisable by JSON.stringify and throw a TypeError, even though they parse cleanly with JSON.parse if presented as plain integers; use a toJSON method on a wrapper class or stringify them to plain strings first. Object key order rules in V8 list integer-like keys numerically first regardless of insertion order, then string keys in insertion order, then Symbol keys (which JSON skips entirely). The U+2028 line separator and U+2029 paragraph separator are valid in JSON strings under modern specs but break older JavaScript parsers that use eval-based JSON handling, so libraries like jsesc escape them defensively. Knowing these quirks turns mysterious cross-runtime drift into a one-line fix at the serialisation boundary.
JSON.stringify also intersects with JavaScript module boundaries in ways that bite during debugging. When logging an object that was loaded from a different realm or worker, properties may not appear because property descriptors mark them non-enumerable; JSON.stringify only walks enumerable own properties. Class instances with private fields lose the private state entirely because private fields are not enumerable own properties of the instance. Proxy objects appear normal but JSON.stringify invokes their ownKeys and getOwnPropertyDescriptor traps, which may return different data than direct property access. For thorough debugging of complex objects, combine JSON.stringify with Object.getOwnPropertyNames or Reflect.ownKeys to enumerate every property name, including non-enumerable ones, and inspect each value explicitly before deciding whether the omission from stringified output is correct or a missing case.
TypeScript adds another layer worth understanding. The TypeScript compiler types JSON.parse as returning any, which defeats type safety unless you assert the result. The common pattern const data = JSON.parse(text) as MyType is unsafe because TypeScript performs no runtime check that the parsed value actually matches the type. Libraries like zod, io-ts, and superstruct add schema validation at the parse boundary, producing a typed value or a clear validation error. For greenfield TypeScript projects, adopt one of these libraries at every API and storage boundary; the small runtime cost prevents an entire category of bugs where TypeScript believes a value is one shape but the runtime value is another. FixTools complements this approach by giving you a quick way to inspect the actual JSON shape before defining the schema.
Paste any JSON string for instant browser-based formatting. Equivalent to running JSON.stringify(JSON.parse(raw), null, 2) in a JavaScript console.
Step-by-step guide to json formatter javascript, beyond json.stringify:
Get your JSON string
Copy the raw JSON string from your API response, log output, build artifact, or config file. If you have a JavaScript object rather than a string, first run JSON.stringify(obj) in your browser console to convert it to a raw JSON string, then copy the resulting string to your clipboard for pasting into FixTools.
Paste into FixTools
Open fixtools.io/json/json-formatter in any browser and paste the raw JSON string into the formatter input area. The input accepts raw JSON text of any length and structure. No preprocessing or escaping is required.
Click Format
Click the Format button. FixTools internally calls JSON.parse() on your input to validate and parse it, then JSON.stringify() with 2-space indentation to produce the formatted output. This is identical to running JSON.stringify(JSON.parse(rawString), null, 2) in a browser console, but with syntax highlighting and a copy button added on top.
Copy the output
Click the Copy button to copy the fully formatted JSON string to your clipboard. Paste it into your code editor, a PR comment, API documentation, or a test fixture file. The output is standards-compliant JSON that any JavaScript parser will accept without modification.
Common situations where this approach makes a real difference:
Non-developer project manager
FixTools extends JSON formatting access to people who do not write JavaScript.
JavaScript developer
Formatting JSON from PR comments or documentation saves review time for the whole team.
React developer
Design-to-code handoffs often involve JSON structures that need formatting to plan the component model.
Test author
Test fixtures for JavaScript API clients should always be reviewed as formatted JSON before committing.
Get better results with these expert suggestions:
JSON.stringify(obj, null, 2) is the canonical JavaScript format command
The pattern JSON.stringify(obj, null, 2) appears in thousands of JavaScript tutorials and debugging guides. Memorize the three arguments: the value to serialize, the replacer (null means include all enumerable own properties), and the indent width (2 produces 2-space indentation). For a tab-indented result, pass "\t" as the third argument instead of 2. This pattern works identically in browser consoles, Node.js, Deno, and Bun.
Use console.dir for non-JSON-serializable objects
Some JavaScript objects contain functions, Symbols, or circular references that JSON.stringify cannot handle and will throw a TypeError for. console.dir(obj) in Chrome DevTools displays the full object tree interactively without needing to serialize it to JSON. For class instances that mix data properties with methods, console.dir is more reliable than JSON.stringify for inspection because it shows all properties including non-serializable ones.
The replacer array filters keys
JSON.stringify(obj, ["name", "age"], 2) produces JSON that includes only the "name" and "age" keys, even if the object has many more properties. The array replacer applies recursively to all nested objects at every depth. This is useful for logging a focused subset of a large object or for producing a sanitized version of a data structure that omits sensitive fields like passwords or tokens.
toJSON() method controls serialization
If a JavaScript object defines a toJSON() method, JSON.stringify() calls it and serializes the return value rather than the object's own properties. This is how Date objects are automatically serialized to ISO 8601 strings. Custom classes can implement toJSON() to control their JSON representation, producing cleaner output than a raw property dump. This is useful for value objects like Money, Duration, or GeoPoint that have a canonical JSON form.
More use-case guides for the same tool:
Other tools you might find useful:
Open the full JSON Formatter — free, no account needed, works on any device.
Open JSON Formatter →Free · No account needed · Works on any device