Free online JSON prettifier
Prettify JSON until you can actually read it
The prettifier is free to use with no sign-in: give it up to 5 MB of JSON and it opens out into an indented tree with 2 spaces, 4 spaces or a tab, values aligned into a column, short arrays left on one line and anything below a chosen depth folded away. It exists for the document that arrived as one 5-million-character line, where plain indentation would give you 430,002 rows and no way in. Long integer IDs, duplicate keys and the order you wrote your properties in all survive the round trip, because the layout is the only thing that changes.
- 100% free
- No signup
- Up to 5 MB
- 2, 4 or tab
- Fold deep branches
The indented tree appears here.
Paste a payload, drop a file, or press Ctrl+V anywhere on this page.
What indentation does each ecosystem write?
There is no standard answer, so the answer is local. If the file has neighbours, match them; if it is going into a repository, match the repository. This is what the common tools do when nobody tells them otherwise.
| Where | What writes it | Indent |
|---|---|---|
| JavaScript | JSON.stringify(value, null, 2) | 2 spaces — you pass the number, and 2 is what almost everyone passes |
| Prettier | any .json it touches | 2 spaces, from the default tabWidth |
| npm | writing package.json | 2 spaces, and it keeps whatever indentation the file already had |
| Python | python -m json.tool, json.dumps(indent=4) | 4 spaces |
| PHP | json_encode($v, JSON_PRETTY_PRINT) | 4 spaces, not configurable |
| AWS CLI | any JSON it prints | 4 spaces |
| jq | jq . — the default filter | 2 spaces; --indent n up to 7, or --tab |
| Ruby | JSON.pretty_generate | 2 spaces |
| Rust | serde_json::to_string_pretty | 2 spaces |
| .NET | JsonSerializerOptions { WriteIndented = true } | 2 spaces; .NET 9 added IndentCharacter and IndentSize |
| Go | json.MarshalIndent(v, "", …) | no default at all — the indent is an argument you have to supply |
| VS Code | Format Document on a .json file | whatever editor.tabSize is, which is 4 out of the box |
The byte cost is small but not nothing: on a 16,002-line array of order records, two-space indentation adds 7.3 bytes per line, four spaces 12.9 and a tab 4.5 — so the same document weighs 309,092, 398,692 and 264,292 bytes respectively, against 192,691 with no whitespace at all.
How to prettify JSON
From an unreadable line to a tree you can navigate, in three moves.
Drop the blob into the left pane
Paste it, hit Ctrl+V from anywhere here, ⌘V on macOS, or drag the file across. A 4.98 MB response that arrived as a single 5,223,326-character line is fine — it parses in under a tenth of a second and comes out as 430,002 lines.
Decide how it should read, not just that it should be indented
Pick 2 spaces, 4 spaces or a tab. Turn on Align values to give every key in an object the same column, leave Short arrays on one line so ["priority", "gift"] stops eating four lines, and set Expand to 2 levels when you only want the shape of a deep config rather than all of it.
Read the counters, then take the result
The bar underneath reports lines in against lines out, the longest line before and after, the nesting depth and the key count, so you can see how much structure you are dealing with. Copy hands over the whole document even though the pane stops drawing at 5,000 lines, and Download writes it out as a .json file.
Technical specifications
| Indent styles | 2 spaces, 4 spaces or a tab. Measured on a 16,002-line array of records: two spaces add 7.3 bytes per line, four spaces 12.9, a tab 4.5 |
|---|---|
| One-line input | A 4.98 MB payload on a single 5,223,326-character line parses in about 0.09 seconds and prints as 430,002 lines |
| Value alignment | Optional; pads each key so values share a column inside their own object, up to a 32-character cap |
| Short array inlining | Arrays holding only strings, numbers, booleans or null stay on one line while the rendered form is 72 characters or fewer |
| Fold depth | Keep 1 to 4 levels expanded; everything deeper prints on one line each, which is how a 500-level document stays readable |
| Key sorting | Optional and recursive, by UTF-16 code point — the same order jq -S produces, so digits sort before uppercase and uppercase before lowercase |
| Kept byte for byte | Number literals of any length, duplicate keys, the original key order, and \uXXXX escapes inside strings |
| Limits and price | 5 MB per document, 500 levels of nesting, 5,000 lines drawn in the preview; free, no signup, no cap on documents, and the parsing happens in your browser |
Frequently asked questions
Should JSON be indented with 2 spaces, 4 spaces or a tab?
Two spaces, unless you are handing the file to an ecosystem that has already decided otherwise. JavaScript, Prettier, npm, jq, Ruby, Rust and .NET all land on two; Python's json.tool, PHP's JSON_PRETTY_PRINT and the AWS CLI all write four; Go has no default because MarshalIndent makes you pass one. The practical rule is to match whatever the file's neighbours use, because a file that changes indentation shows up as a whole-file diff the next time anyone touches it.
Does prettifying JSON change what the data means?
No. RFC 8259 allows space, tab, carriage return and line feed between any two tokens and gives that whitespace no meaning, so indenting a document, aligning its values or folding a deep branch onto one line all produce the same parsed value. Re-minify anything this page prints and you get the bytes you started with, character for character — the layout is the only thing that moved.
What does “Align values” actually do to the file?
It pads each key with spaces so every value inside one object starts in the same column, which turns an array of similarly shaped records into something you can read down like a table. Two things are worth knowing before you commit it: the padding is real bytes, and the column is set by the longest key in that object, so adding one long property name re-indents every sibling line and your next git diff shows the whole block as changed. Alignment caps at 32 characters here, so a single freak key cannot push the values off the screen.
How do I read a 5 MB JSON file that is all on one line?
Fold it before you read it: set Expand to 2 levels and the top of the document lays out normally while everything below stays on one line each, so you get the shape without 430,002 rows of detail. That is the measured figure — a 4.98 MB single-line array of order records becomes 430,002 lines at two-space indentation, and drawing all of them is what makes a browser tab stall. The pane here stops at 5,000 lines for that reason, while Copy and Download still hand over the whole thing.
Will prettifying round off my long ID numbers?
Not here, because a number is never turned into a JavaScript number in the first place. Anything above 9,007,199,254,740,991 is stored as the nearest 64-bit float once JSON.parse touches it, and whether that shows depends on pure luck: 1275892450392698880 survives because a double happens to hold it exactly, while 1275892450392698881 comes back as ...880 and 12345678901234567890 comes back as 12345678901234567168. This page prints the literal you typed, so trailing zeros in 1.500 and every digit of a snowflake ID are still there afterwards.
Why does my editor produce different pretty-printed JSON from this page?
Because no standard says what pretty-printed JSON should look like. RFC 8259 defines where whitespace may appear and stops there, so every implementation invents the rest: whether a space follows the colon, whether an empty object prints as {} or across two lines, whether a short array of numbers stays inline, and how a top-level scalar is treated. Those choices are why two formatters can both be correct and still disagree on almost every line of the same file.
Is indented JSON slower to parse than minified JSON?
Barely, and not enough to choose layout on: V8's JSON.parse reads the 8.35 MB indented form of a document and its 5.22 MB minified form in the same 18 milliseconds, because skipping whitespace is close to free next to building the values. The cost of indentation is bytes on the wire and in storage, not CPU at the far end, which is why the sensible split is pretty in the repository and minified in the request.
About making JSON readable
Pretty-printing is the part of JSON that the specification declines to have an opinion about. RFC 8259 says where whitespace may go — between any two structural tokens — and says nothing at all about where it should go, which is why every language ships a different answer and why a file reformatted by the wrong tool arrives as a thousand-line diff with no content change in it. The useful consequence is that layout is always safe to change: fold a branch, align a column, swap tabs for spaces, and the parsed value is identical. The unhelpful consequence is that “prettified” means nothing precise, so a team that cares has to write its choice down somewhere a formatter can read it.
Readability is also not the same problem as indentation, which is what most prettifiers get wrong. A payload with 400 records in it does not become readable when each record is spread over 40 lines; it becomes 16,000 lines of scrolling. What actually helps is reducing what you are shown: keeping ["priority", "gift"] on the line that introduces it, giving every value in a record the same column so the block reads as a table, and folding everything below the second level so the top of a deep config fits on one screen. Those three switches are the difference between a document you can skim and one you can only search. When even that is too much, a collapsible tree view is the better instrument, because it draws nothing you have not opened.
One detail decides whether a prettifier can be trusted with production data: what it does to numbers. The obvious implementation parses to JavaScript values and prints them back, and every integer above 9,007,199,254,740,991 loses its tail in the process, along with the trailing zeros of a fixed-decimal price and the second of any two duplicate keys. This page works on the source text, so a 19-digit order ID comes out with all 19 digits. That fidelity is also what makes the reverse trip safe: when the file is going back into a request body or an environment variable, you can strip the whitespace back out and get exactly the bytes you were given, whitespace being 37.8% of a two-space document and the only thing that was ever added.
Where the payload is laid out
The parser and the printer are JavaScript in the tab you have open, so the document you paste is never uploaded, stored or logged — a production webhook body can be opened here without it leaving the machine. Turn the network off after the page has loaded and everything on it still works.