Free online JSON formatter. Paste JSON or add a .json or .txt file, select a 2 or 4 space indent, press Format and copy or download the result. Minify, Sort Keys, Remove Nulls, Escape and Unescape sit in the same bar.
Developer tools by OnlinePCApps since 2013
A minified API response is one long line, and a broken payload fails without saying where. The free online JSON formatter makes it readable and flags it when it will not parse.
An API response or a webhook body often arrives minified, one dense line with no spacing. The online JSON formatter adds indentation and line breaks, so the nesting and the shape of the data become clear at a glance.
A trailing comma or a missing quote breaks an entire payload, and a plain parser only says it failed. A status light turns red with Invalid JSON and the parser message shows under the Input box, so the one bad character is found sooner.
Once the JSON is valid, six tiles show its Depth, Keys, Arrays, Characters, Minified size and Formatted size. The online JSON formatter shows how deep a payload nests and how many bytes minifying saves before it goes anywhere.
Paste the JSON into the Input box of the online JSON formatter, or select Upload to add a .json or .txt file. An API response, a config, a webhook body or any JSON text works as input.
Select a 2 or 4 space indent, then press Format to beautify or Minify for one compact line. A status light shows Valid JSON or Invalid JSON as you type, and Sort Keys, Remove Nulls, Escape and Unescape sit in the same bar.
Select Copy for the Output, Copy Minified for one line or Download to save output.json. The online JSON formatter keeps the input as it was, so the same JSON can be formatted again with the other indent.
To format JSON is to tidy, validate or compact the same data. The online JSON formatter does all three from one bar.
The online JSON formatter pretty-prints the JSON with a 2 or 4 space indent, so the nesting stays clear. Only the whitespace moves, since every key and value stays as it was. The panel has no tab option.
Minify strips every space and newline to the most compact valid JSON, the form a production payload ships in. Copy Minified puts that one line on the clipboard without touching the Output box.
A status light shows Valid JSON or Invalid JSON as you paste. On an error, the parser message shows under the Input box, like an unexpected token or a missing quote. A valid payload is confirmed at once.
Sort Keys puts the keys of every object in alphabetical order. Remove Nulls drops null members. Escape turns the JSON into one string, and Unescape turns a JSON string back into plain text.
To format JSON, to beautify a payload and to validate a config all name one task. A search for online JSON formatter or JSON validator reaches the online JSON formatter above, and the input stays as it is.
JSON has a strict grammar, and the online JSON formatter tidies without touching the data. The cases below run from clean to not on this page.
| The case | Result | What happens and why |
|---|---|---|
| Beautify | 2 or 4 space | The online JSON formatter pretty-prints with the chosen indent. There is no tab option. |
| Minify | one line | Strips every space and newline to the most compact valid JSON. |
| Validate | status light | Shows Valid JSON or Invalid JSON as you type, with the parser message under the Input box. There is no line pointer or repair. |
| Data types | six only | String, number, boolean, null, object and array only. |
| Strict rules | RFC 8259 | Double-quoted keys, no trailing comma and no comments in standard JSON. |
| JSON5 | rejected | Single quotes, trailing commas and comments are flagged, not accepted. |
| Big numbers | precision | An integer beyond the safe range can lose precision as a 64-bit float. |
| Duplicate keys | deduplicated | A repeated key is collapsed to the last value on the parse round trip. |
| Sort Keys | a to z | The online JSON formatter puts the keys of every object in alphabetical order. Format alone keeps the order that arrived. |
| Remove Nulls | drops null | Removes every member whose value is null, at every level. |
| Escape and Unescape | JSON string | Escape wraps the text as one JSON string. Unescape expects a quoted string like "hello". For why escaping is not encryption, see Hashing vs encryption vs encoding and what each does. |
| Stats | six tiles | Depth, Keys, Arrays, Characters, Minified size and Formatted size, once the JSON is valid. |
| Source file | .json .txt | Paste the text or select Upload. For broken characters in a file, see Character encoding explained and why text arrives broken. |
| Output | output.json | The online JSON formatter offers Copy, Copy Minified and Download. A tree view is not on this page. |
| Where it runs | on the device | The JSON is formatted in the browser, so nothing is uploaded. |
How JSON Formatting Works
JSON, short for JavaScript Object Notation, is a text format for data made of six building blocks: a string, a number, a boolean, null, an object and an array. It came out of work by Douglas Crockford and is now fixed by two standards that agree, RFC 8259 and ECMA-404. Formatting does not alter the data, only its shape on the page. The online JSON formatter parses the text and outputs it again, with an indent for a beautify or with none for a minify, so the same payload stays clear or ships compact. The strict grammar is where the honest points live. Standard JSON needs double-quoted keys, allows no trailing comma and permits no comment, which is exactly why a payload copied from JavaScript often fails to validate in an online JSON formatter. Those relaxed features belong to JSON5, a separate superset that shows as Invalid JSON here. Two more points are worth stating. A number beyond the safe integer range can lose precision, since JSON numbers ride on a 64-bit float, and a duplicate key is collapsed to its last value when the data round-trips through a parser. The references below define the standard.
Both the online JSON formatter and the command line format JSON. The trade is between a quick visual tidy and a scriptable query engine.
| Point of comparison | This tool Online JSON formatter On the device | The command line A local terminal tool |
|---|---|---|
| Where the payload goes | Stays in the browser | Stays on the machine |
| Price and caps | Free with no sign-up | Free tier often capped |
| A multi-gigabyte file | Built for one payload per run | Streams from disk |
| Query and transform | Format, sort and clean only | jq filters and reshapes |
| A quick tidy or check | Paste, press Format, done | A filter to write first |
jq on the command line wins for a multi-gigabyte file or a query that filters and reshapes the data in a script. The online JSON formatter wins for a fast beautify, minify or check with a status light and no install. Online file tools and whether yours uploads goes deeper on where a payload goes.
The JSON is parsed and re-serialized inside the browser by the native JSON.parse and JSON.stringify, so the work is client-side and the payload stays on the machine that opened it. Nothing is handed to a server to format it.
A JSON payload often carries an access token, an API key or real user records never meant for an outside server. A hosted formatter has to receive all of that on upload, needless exposure when the browser can tidy it locally.
All of these format JSON. They vary on reach, on effort and on where the payload goes.
jq, an editor and a console all format JSON, yet every one needs a query language, an open file or the terminal. The online JSON formatter above needs only a browser and shows a live status light.
Three pointers save a puzzling error in the online JSON formatter.
Standard JSON allows no trailing comma, no comment and no single quotes. Those are JSON5 features, and pasting them in will flag an error. Remove the non-standard syntax first, then format the strict JSON that is left.
A JSON number rides on a 64-bit float, so an integer beyond the safe range, like a long ID, can lose precision on a round trip through an online JSON formatter. Where an exact big number matters, carry it as a string rather than a number.
Standard JSON does not forbid a repeated key, but a parser keeps only the last one. So the online JSON formatter silently drops the earlier duplicate on a beautify, which is worth knowing if a payload was built with a key written twice.
The online JSON formatter takes one payload per run, which suits most debugging. A multi-gigabyte file, a folder of JSON or a query that filters the data belongs on jq or the desktop edition, and both work from disk.
A multi-gigabyte file is streamed from disk and formatted, past what one paste on this page is built for.
jq filters, maps and reshapes the data with a query, far past what a beautify or a minify does on its own.
A format or validate step runs inside a build or a hook, so a payload is checked automatically, ready for a repeated workflow.
No sign-up and no cost. Paste JSON into the online JSON formatter, select an indent and press Format.