How to use this JSON formatter
Paste your JSON into the top box — copied from an API response, a log file, a database export or a config file — then press “Format / Beautify”. The tool parses the text and re-prints it with one value per line and a consistent indent, so nested objects and arrays finally show their shape. Choose 2 or 4 spaces for the indent, and tick “Sort keys” if you want every object's keys rearranged from A to Z. The finished text appears in the result box with a character count, ready to copy or download as a .json file.
If the JSON is broken, you will not get a silent failure. The tool shows the parser's own description of the problem and, where the browser reports a position, the exact line and column to look at — plus a short list of the usual suspects. That makes this page a practical first stop when an API, a webhook or a hand-edited config file starts misbehaving: paste, read the message, fix the comma or quote, and format again. The “Validate only” button runs just the check without re-printing anything, for when you only need a yes-or-no answer.
Minify does the opposite journey: it strips every line break and indent and returns the JSON as a single compact line, exactly the way production systems send it over the wire. Round-tripping between the two views is also a quiet integrity check — format a minified document and minify it again, and you should land back on byte-identical text, because formatting never changes the data itself, only the whitespace around it.
Example: one line in, structure out
This typical cramped API response:
becomes, with a 2-space indent:
Same data, same order — but now the nesting is visible at a glance, a missing field stands out, and a colleague can review it without squinting at a 200-character line.
Why sorted keys make diffs painless
JSON objects make no promise about key order, so two exports of the very same record often list keys in different sequences — and a line-by-line comparison then reports hundreds of meaningless changes. Sorting keys alphabetically, at every level of nesting, forces the same key into the same position in both documents. Diff the two sorted outputs and only the genuine changes remain. It is a small trick that saves real time when you are comparing API responses before and after a release, or checking what a settings file actually changed.
The five mistakes behind almost every invalid JSON error
Nearly every broken document fails for one of five reasons. Trailing commas — a comma after the last item in an object or array — are legal in JavaScript code but forbidden in JSON. Single quotes look harmless but are never allowed; strings and keys must use double quotes. Keys must be quoted at all: {name: "Ada"} is invalid, {"name": "Ada"} is fine. Comments, handy in config files for other formats, have no place in strict JSON. And the classic: a missing comma or closing bracket somewhere above where the parser finally gives up — which is why the reported position is where the parser noticed the problem, not always where the mistake lives. Work upwards from the reported line and you will usually find it within a few lines.
JSON is not quite JavaScript — and not quite a config file
JSON grew out of JavaScript's object syntax, which is why the two look alike and why the differences catch people out. A JavaScript object in code may use single quotes, unquoted keys, trailing commas, comments and even functions as values; a JSON document may use none of those, because JSON is a data format meant to be read identically by every language, not a programming language itself. It also explains the other common surprise: JSON has no date type and no way to write comments, so dates travel as text strings and explanations have to live outside the file. When a hand-edited file fails validation, it is almost always because it was written to JavaScript's looser rules rather than JSON's strict ones — paste it here, fix what the error message names, and the formatted output will obey the strict rules exactly.
Frequently asked questions
Is my JSON uploaded to a server?
No. Parsing, formatting and validating all happen in JavaScript inside your own browser. Your JSON — including API responses with private or work data — never leaves your device, and the tool still works offline once the page has loaded.
What is the difference between formatting and validating?
Validating only checks whether your text obeys the JSON rules and reports the first problem it finds. Formatting goes further: it parses the JSON and re-prints it with consistent indentation, one value per line, so the structure is easy to read. Invalid JSON cannot be formatted — fix the error the validator points to first.
Will formatting change my data?
No. Formatting changes only whitespace — line breaks and indentation. Keys, values, order of array items and number values stay the same, unless you deliberately tick “Sort keys”, which reorders object keys alphabetically. One honest caveat: integers with more than about 16 digits can lose precision in any JavaScript tool, because of how browsers store numbers.
What does sorting keys do?
It reorders every object's keys from A to Z, including objects nested inside other objects, while arrays keep their order. Sorted output makes two JSON documents easy to compare line by line, because the same key always lands in the same place.
Why does the validator say my JSON is invalid?
The most common causes are a comma after the last item in a list (JSON forbids trailing commas), single quotes instead of double quotes, keys written without quotes, comments left in the text, or a missing comma or closing bracket. The error message above the tool names the problem and, where the browser reports it, the line and column to look at.
Should I indent with 2 or 4 spaces?
Both are correct — it is purely a style choice. Two spaces is the most common convention in JavaScript projects and keeps deeply nested data compact; four spaces is easier to scan in shallow documents. Pick whichever your team or the file you are editing already uses.
What is minified JSON used for?
Minifying removes every line break and indent, producing the smallest possible file. That is what production APIs send over the wire, and it is handy when you need JSON on a single line — inside a header, a database field, a log entry or a command-line command.
How large a JSON document can this handle?
There is no limit set by the tool. Pasted documents of several megabytes format fine on most modern laptops and phones; extremely large files are limited only by your device's memory and the speed of its processor.
Can I download the formatted result?
Yes. After formatting or minifying, the Download button saves the result as a formatted.json file, and the Copy button puts it on your clipboard — both work on the exact text shown in the output box.