Free · Fast · Privacy-first

Pretty Print JSON Online

Pretty printing JSON is the act of turning a compressed, machine-friendly string into a structured, human-friendly view with consistent indentation and one token per line.

Native JSON.parse and JSON.stringify under the hood

🔒

Choose 2-space, 4-space, or tab indentation

Syntax highlighting by token type

No network calls during pretty printing

Cost
Free forever
Sign-up
Not required
Processing
In your browser
Privacy
Files stay local
FreeNo signupWhite-label

Add this JSON Formatter to your website

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.

  • Files stay 100% in the visitor's browser
  • Responsive — adapts to any container width
  • Free forever, no API key needed

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.

What Pretty Printing Actually Changes, and What It Does Not

Pretty printing JSON inserts whitespace at the positions surrounding structural characters, which are the opening and closing brackets and braces, colons between keys and values, and commas between items. RFC 8259 defines those positions as whitespace-tolerant, meaning a conforming parser must ignore any spaces, tabs, carriage returns, and newlines that appear there. The string content inside a quoted JSON string is not touched by pretty printing because the contents of a string token are semantically meaningful: a newline character inside a string is part of that string value and would change the parsed result if altered. The pretty printer therefore preserves every byte of every string value while adding visual structure around the tokens.

A common source of confusion is that pretty printing does not normalise the data in any other way. Key ordering inside an object is preserved as-is by JSON.stringify in modern JavaScript engines, with the exception that integer-like keys (keys that look like array indices) are emitted in numeric order first per the V8 enumeration rules. Numeric values keep their original representation only if they survive a round trip through JavaScript number precision: 1.0 becomes 1, 1e10 becomes 10000000000, and any value beyond the safe integer range may lose precision. If your JSON contains identifiers stored as numbers larger than 2^53, the pretty printer may silently truncate them. Store such values as strings in the source to avoid this entire category of bug.

Pretty printing is also not the same as canonicalising. Canonical JSON, as defined in drafts such as RFC 8785 JCS, mandates a specific key order, a specific number serialisation, and a specific escaping rule, so two structurally equivalent documents always produce byte-identical output. Standard pretty printing makes no such guarantees. If your workflow needs canonical output for signing, hashing, or content-addressable storage, run the pretty printed result through a JCS-conformant tool afterwards. For everyday human-readable inspection, the relaxed approach used by JSON.stringify is appropriate and matches what every developer expects from a browser-based formatter.

The pretty printer in FixTools handles a few practical edge cases that the bare JSON.stringify call does not. Inputs prefixed with a UTF-8 byte order mark are accepted because the tool strips the BOM before calling JSON.parse, whereas a raw JSON.parse call would reject any non-whitespace character at position zero. Inputs that contain a trailing newline or trailing whitespace after the document terminator are accepted because the tool trims surrounding whitespace first. Inputs that contain a single JSON document wrapped in additional whitespace inside a larger text block are not parsed automatically; extract the JSON region first and paste only that. These behaviours match what experienced developers expect from a forgiving formatter without silently changing the data.

Performance for typical inputs is bounded by rendering rather than parsing. JSON.parse in V8 runs at roughly 200 to 500 megabytes per second, and JSON.stringify with an indent argument runs at similar speeds because it walks the same parsed tree. The slow part of pretty printing in a browser is producing the syntax-highlighted DOM: every key, value, and structural character becomes a styled span, which can multiply the node count of the displayed text by an order of magnitude compared to plain text. For documents under 5 megabytes this is imperceptible. For documents in the 10 to 50 megabyte range expect a brief pause. For documents over 100 megabytes prefer a streaming command-line tool such as jq, which produces pretty printed output with constant memory regardless of file size.

How to use this tool

💡

Paste your JSON, pick an indent width, and click Format. The pretty printed output appears on the right with syntax highlighting and a copy button.

How It Works

Step-by-step guide to pretty print json online:

  1. 1

    Paste your JSON

    Paste any minified, raw, or partially indented JSON into the input area. The pretty printer accepts any input string and does not require you to clean it up first. If the input contains a leading UTF-8 byte order mark, the tool strips it silently before parsing so the result matches what a strict downstream parser will see.

  2. 2

    Select an indent width

    Choose 2 spaces, 4 spaces, or tabs. The default of 2 spaces matches the convention used by most JavaScript and TypeScript projects following the Airbnb and Google style guides. Pick 4 spaces if your project follows Python PEP 8 conventions for JSON config files, and pick tabs if your team prefers editor-configurable indent display widths.

  3. 3

    Click Pretty Print

    Click the Format button. The tool calls JSON.parse on your input, then JSON.stringify with the chosen indent value, and renders the result with syntax colouring. If parsing fails, the line and column of the first error are shown instead of output, so you can navigate directly to the broken token.

  4. 4

    Copy the result

    Use the one-click copy button to copy the pretty printed JSON to your clipboard. Paste it into your editor, your documentation source, your pull request description, or your team chat. The output is standard indented JSON that any RFC 8259 conformant parser will read back identically to the input.

Real-world examples

Common situations where this approach makes a real difference:

API engineer

Pretty printing makes null versus missing distinctions immediately visible in a way that single-line JSON hides.

Open source maintainer

Whitespace-only diffs disappear when both sides are pretty printed with matching settings.

Support engineer

Hidden whitespace inside string values is visible in pretty printed output when string boundaries are clearly delineated by quotes.

Data engineer

Schema discovery from pretty printed samples is faster than reading the vendor documentation when the documentation lags the actual payload.

Pro tips

Get better results with these expert suggestions:

1

Match your project indent style

Before committing a JSON config file, pretty print it with the same indent width your repository uses. Repositories that follow .editorconfig or Prettier configuration typically settle on 2 spaces for JavaScript projects and 4 spaces for Python projects. Matching the existing style keeps your diff focused on real changes rather than a wall of whitespace updates that obscure the actual modification and force reviewers to look harder than they should.

2

Pretty print before logging

When debugging a service that emits JSON to a log file, log the pretty printed form during development and the single-line form in production. Pretty printed log lines are easy to scan in a terminal, while single-line entries are easier for log shippers like Fluentd or Vector to parse one record per line. A conditional based on NODE_ENV or a similar environment variable lets you switch between the two without changing application code.

3

Use indent 2 for documentation samples

API reference documentation typically uses 2-space indented JSON examples because the output fits in narrower content columns without horizontal scrolling. Wider indentation pushes deeply nested values off the right edge of typical 80-character documentation columns. Two-space indent strikes a good balance between visible structure and column width for documentation that needs to render cleanly on both desktop and mobile reader devices.

4

Combine with jq for large files

For files larger than 50 megabytes, run jq . input.json > pretty.json at the command line before opening the result in an editor. jq streams the input and writes the pretty printed output without holding the entire structure in memory the way a browser would. The output is identical to what an in-browser pretty printer would produce for smaller files, so the workflow scales smoothly from kilobyte to gigabyte inputs without changing your downstream consumption pattern.

FAQ

Frequently asked questions

Pretty printing JSON means adding whitespace, line breaks, and indentation to a JSON text so that the structure is easy for a human to read at a glance. The JSON specification defined in RFC 8259 allows any amount of whitespace between tokens, so pretty printers insert spaces and newlines at structurally meaningful positions without changing the parsed data. A single-line minified JSON document and a fully pretty printed multi-line document with 2-space indentation produce identical results when passed through any conforming JSON parser, in any language, on any platform.
Pretty print, beautify, and format all describe the same operation when applied to JSON: inserting insignificant whitespace at legal positions in the document to make the structure visually clearer. Different developer communities prefer different terms based on their primary language background. Python developers tend to say pretty print because json.dumps takes an indent parameter and the Python json module documentation uses the term. JavaScript developers often say stringify with indent because that is the JSON.stringify call signature. Web tooling communities say beautify or format. All three terms produce the same kind of output and the same parsed result.
No. Pretty printing only adds whitespace at positions that RFC 8259 designates as whitespace-tolerant. The string contents inside quoted JSON string values are never touched, so any whitespace, escape sequences, or Unicode characters inside strings are preserved byte-for-byte. The result, when parsed, produces a data structure identical to what the original input parses to. The only thing that changes is the human readability of the text representation, not the semantic content of the document or any string value within it.
Two spaces is the most common choice in modern web development and matches the default used by Prettier, the Airbnb JavaScript style guide, and the Google JSON style guide. Four spaces is more common in Python projects that follow PEP 8 conventions and in some Java codebases. Tab indentation is preferred by some Go projects and by developers who like each reader to configure their own tab display width in their editor. Choose whichever matches your project conventions; all three options produce equally valid JSON that any conforming parser reads identically and that round-trips losslessly through any pipeline.
Yes for files up to several tens of megabytes. The browser parses and stringifies the document quickly because V8 and the equivalent engines in other browsers are heavily optimised for JSON. The bottleneck for larger files is DOM rendering of the syntax-highlighted output. For files between 50 megabytes and 200 megabytes expect a noticeable pause while the browser commits layout. For files above 200 megabytes use the jq command-line tool, which streams the input and produces pretty printed output with constant memory regardless of file size. jq is available through Homebrew on macOS, apt on Linux, and the official releases page on Windows.
No. Pretty printing requires that the input first parses as valid JSON. If your input contains a syntax error such as a trailing comma, an unquoted key, a single-quoted string, or a missing bracket, the parser rejects the input and the pretty printer cannot produce output until the source is corrected. The tool reports the exact line and column of the first parse error, which lets you navigate to the offending token and fix it. Once the source parses cleanly, pretty printing succeeds. Tools like JSON5 widen the accepted grammar and can parse some of these cases, but the strict pretty printer follows RFC 8259.
Pretty printed JSON is larger than minified JSON, often by 20 to 40 percent because of the extra whitespace and newlines. For files stored on disk or sent over a network, this size difference can matter at scale, which is why production APIs typically respond with minified JSON and use gzip compression on top. For developer-facing artefacts such as documentation samples, configuration files, and test fixtures, the readability benefit of pretty printing outweighs the size cost. A common pattern is to store pretty printed JSON in version control for readable diffs, and to minify it at build time before deployment.

Related guides

More use-case guides for the same tool:

Ready to get started?

Open the full JSON Formatter — free, no account needed, works on any device.

Open JSON Formatter →

Free · No account needed · Works on any device