"Pretty print" is the developer shorthand for formatting JSON with proper indentation so the nested structure is easy to read and navigate.
Loading JSON Formatter…
Pretty prints in one click
Validates before printing
Configurable indentation
No server, fully private
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.
JavaScript has had a built-in JSON pretty printer since ECMAScript 5, standardised in 2009. The JSON.stringify() function accepts three arguments: the value to serialise, a replacer (usually null to include all properties), and a space argument. When the space argument is a positive integer, JSON.stringify inserts that many space characters after each colon, after each comma, and at each new nesting level with a newline before the indentation. JSON.stringify(obj, null, 2) produces 2-space indented output. JSON.stringify(obj, null, 4) produces 4-space indented output. You can also pass a string as the space argument, for example the tab character "\t", to produce tab-indented output. The ECMAScript specification caps the integer form at 10 spaces maximum.
The same pattern exists in every major programming language with a standard JSON library. Python's json.dumps(obj, indent=2) behaves identically, inserting 2 spaces per nesting level. Ruby's JSON.pretty_generate(obj) defaults to 2-space indentation. Go's json.MarshalIndent(v, "", " ") takes a prefix string and an indent string as separate arguments. Java's Jackson library has ObjectMapper().writerWithDefaultPrettyPrinter(). These are all implementations of the same concept defined by the JSON specification: insert insignificant whitespace at the positions allowed between tokens so that a human reader can follow the nesting structure without a machine caring either way.
When you use FixTools as a JSON pretty printer, the underlying operation mirrors what JSON.stringify does natively in the browser. The input is first passed through JSON.parse() to validate it and convert it to a JavaScript data structure. If parsing succeeds, JSON.stringify() is called with your chosen indent value to produce the pretty-printed output string. The browser's native JSON engine handles both operations with high-performance compiled code, which is why formatting is instantaneous even for moderately large payloads. FixTools adds syntax colour-coding on top, which the raw stringify output does not include but which significantly aids navigation in large or deeply nested documents.
Pretty printers expose JSON spec edge cases that compact output hides. The number grammar in RFC 8259 forbids leading zeros (007 is invalid), hexadecimal literals (0xFF is invalid), and the JavaScript special values NaN, Infinity, and -Infinity. When a pretty printer chokes on a number that looks valid in source code, it is usually one of these. Strings have their own pitfalls: lone surrogate code points such as a high surrogate without its low pair are technically allowed by the standard but break many downstream parsers. Comments are not part of JSON at all, even though VS Code accepts them in tsconfig.json files because that file is treated as JSONC. A strict pretty printer reveals all of these issues by refusing to print the input, pointing you directly at the offending byte.
Key preservation deserves explicit treatment because it interacts with both human readability and machine determinism. JSON.stringify and Python json.dumps preserve the source key order for string keys in modern runtimes, which keeps related fields visually grouped in the pretty-printed output. Sorting keys alphabetically is sometimes preferable, especially for canonical hashing, deterministic diffs in code review, or comparing two documents that were built in different orders. Pass sort_keys=True in Python or use a key-sorted serialiser in JavaScript such as json-stable-stringify when determinism matters. For large objects with many keys, the readability cost of alphabetical sort is usually worth the determinism benefit because reviewers can find any key by binary scan rather than reading every parent context to predict where it lives.
Paste your JSON and use the Format button to pretty print it with your preferred indentation style.
Step-by-step guide to json pretty printer:
Paste your JSON string
Paste the JSON you want to pretty print into the editor input area. The editor accepts any JSON regardless of its current formatting, including fully minified single-line JSON, partially indented JSON, and JSON with inconsistent whitespace throughout.
Select indentation
Choose 2 spaces, 4 spaces, or tabs from the indentation options. The default is 2 spaces, which is the most common setting for JavaScript and TypeScript projects. Select 4 spaces for Python-style output or tabs for Go-style output.
Click Format
FixTools validates the JSON and pretty prints it with your chosen indentation. The output appears immediately with syntax highlighting that colour-codes keys, string values, numbers, booleans, and structural characters for easy navigation.
Common situations where this approach makes a real difference:
JavaScript developer
A developer building a Node.js script that fetches data from an external REST API logs the raw response body during development and sees a compressed single-line string. Running JSON.stringify(body, null, 2) in the console, or pasting the body into FixTools, reveals a nested "items" array where each item contains a "metadata" object with a "source" field the developer had not seen in the API documentation. Knowing this field exists allows them to write the correct property access path and prevents a runtime undefined error in production.
Teacher
A programming instructor uses pretty-printed JSON to explain data structure concepts to students who are new to REST APIs. By formatting sample responses from public APIs like the GitHub API or OpenWeatherMap API, the instructor produces clean indented examples that show nesting levels with visual clarity. Students can see the difference between a top-level field, a nested object field, and a field inside an array element without needing to understand parsing code first.
Mobile app developer
An iOS developer uses Xcode's network inspector to capture a backend API response during a debugging session. The response body is displayed as raw unformatted text in the inspector. Copying the response and pasting it into FixTools to pretty print it reveals that a field expected to contain a string array is actually a single comma-separated string. This explains exactly why the mobile client's array parsing code is failing and points to the backend endpoint that needs to be fixed.
Database administrator
A DBA exports a JSON document from a MongoDB collection and needs to review its full schema before writing a migration script. Pretty printing the exported document in FixTools reveals the complete key hierarchy, including several deeply nested sub-objects three levels below the root that would have required counting characters to find in the raw single-line output. The formatted view shows the correct field paths for the migration script without any manual parsing.
Get better results with these expert suggestions:
Use null as replacer to include all keys
JSON.stringify(obj, null, 2) passes null as the replacer argument, which tells stringify to include all enumerable own properties of the object. If you pass an array of strings as the replacer, only the keys named in that array appear in the output, which is useful for producing a focused subset view. For a complete pretty print that includes every field, null is the correct replacer value and the one you should use for debugging and documentation purposes.
Pretty print in browser console quickly
In any browser DevTools console, type JSON.stringify(someObject, null, 2) and press Enter to see a pretty-printed version of any JavaScript object that is in scope on the current page. This works without switching to an external tool and without installing anything. For objects already serialised as strings, use JSON.stringify(JSON.parse(jsonString), null, 2) to parse first and then pretty print.
The space limit is 10 in the spec
Per the ECMAScript specification, if you pass an integer greater than 10 to JSON.stringify as the space argument, it is silently clamped to 10 spaces. You cannot produce more than 10 spaces of indentation per level using the native stringify function. For unusual indentation widths, use a post-processing step or a formatter that applies custom indentation after the fact.
Pretty print for logging in Node.js
In Node.js scripts and server applications, console.log(JSON.stringify(data, null, 2)) pretty prints any JavaScript object to stdout with 2-space indentation. For production logging this adds verbosity, but during local development it makes deeply nested response objects, database query results, and configuration objects readable without switching to an external tool.
More use-case guides for the same tool:
Open the full JSON Formatter — free, no account needed, works on any device.
Open JSON Formatter →Free · No account needed · Works on any device