JSON Beautify & Compact screenshot

JSON Beautify & Compact

Switch JSON between a pretty two- or four-space layout and a compact single line, in place.

Privacy First
0 Runs
Updated 2026-11-06
No upload
Instant
No signup

What this page computes

Paste JSON and choose a layout. The page parses the text once with JSON.parse, then re-emits it with JSON.stringify: two or four spaces of indentation for the pretty form, no whitespace at all for the compact one. The rebuilt document is printed first and a line and character count underneath it, so you can see what the layout cost before copying it.

Where it stops

The parser is strict JSON, so comments, trailing commas, single quotes, NaN and the rest of JSON5 are refused with the parser's own message rather than repaired into something you did not write. Numbers are re-serialised by the engine, which means 1.0 prints as 1 and a value beyond double precision loses the digits it never had. A repeated key keeps the last value, because that is what parsing into an object does.

Parsing and re-emitting happen in this tab. Nothing is uploaded, nothing is stored, and the same text always prints the same document.

One parse, one re-emit: pasted JSON comes back indented by two or four spaces, or compacted to a single line with no whitespace at all. A line and character count closes the output.

The parser is strict JSON, so comments, trailing commas and single quotes are refused with the parser's own message instead of being repaired.

How to use it

Paste the document, choose a layout and press Run. Reformatting never changes the order of keys: the parse keeps insertion order and the emit writes it back.

The arithmetic

`JSON.parse` builds a value, `JSON.stringify` writes it with an indent of two, four or none. The count is of the rebuilt text, so it includes braces, quotes and newlines but not any whitespace the original had.

Where it stops

A syntax error is reported with the engine's position message, and no repair is attempted. Duplicate keys collapse to the last one because an object cannot hold two, and integers beyond double precision lose the digits the parse never kept.

What to Expect

Best for

  • One parse, one re-emit: pasted JSON comes back indented by two or four spaces, or compacted to a single line with no whitespace at all.
  • Seeing the result before copying it.

What this tool keeps

  • Your input is converted in the browser and never posted, so the page works offline and retains nothing.

Sample input

{"name":"Ada","roles":["engineer","analyst"],"years":7}

Sample output

{ "name": "Ada", "roles": [ "engineer", "analyst" ], "years": 7 } pretty, 2-space indent → 8 lines, 81 characters

Frequently asked questions

How do I use it?

Paste the JSON, choose pretty or compact, then press Run. With pretty, pick two or four spaces; the reformatted document is printed first and its size underneath.

Is anything uploaded?

No. The text is converted in this tab with JavaScript: no request is made, no account is needed, nothing is stored, and the page keeps working offline once loaded.

What are its limits?

Only strict JSON is accepted, so JSON5 features must be refused rather than silently fixed. Numbers are re-serialised by the engine, which means 1.0 prints as 1, and a repeated key keeps the last value.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.