JSON Formatter
Pretty-print messy JSON and spot the error if it won't parse.
Everything runs inside your browser. Your files never leave your device.
Input
Result
Ask about JSON Formatter
Questions about what this tool does, which option to pick, or what it can and cannot handle.
This is the one part of the site that uses a server. The question you type here is sent to an AI provider to be answered — your files and whatever you put in the tool above are not, and the assistant cannot see them. Answers are generated and can be wrong; the tool itself is not guessing.
About the JSON Formatter
JSON arrives ugly. An API returns it on one enormous line, a log file wraps it at column eighty, someone pastes it out of a browser console with the quotes half-escaped. None of that is readable, and reading it is usually the whole task — you are looking for one field, or checking whether the shape matches what your code expects.
This formatter reparses the document and prints it back with consistent indentation, so the structure becomes visible rather than inferred. You can indent with two spaces, four spaces or a tab, and optionally sort every object's keys alphabetically. That last option is more useful than it sounds: two API responses that list their fields in different orders look completely different in a diff, and sorting both makes the real difference obvious.
When the document does not parse, the tool does something most formatters skip. Rather than repeating the browser's message — which is often a truncated snippet and no position at all — it scans the text itself and reports the line and column of the first character that cannot belong to valid JSON. A trailing comma before a closing brace, an unterminated string, a missing bracket: each gets a location you can jump to.
Nothing is uploaded. The document is parsed by your own browser, which means you can safely paste a production payload, an access token or a customer record into it. There is no server to receive them and no log for them to land in.
How to use it
- 1Paste your JSON into the input box, or press “Try an example” to see the tool work on a sample document.
- 2Choose your indentation — two spaces, four spaces or a tab — in the options on the right.
- 3Turn on “Sort keys alphabetically” if you are about to compare this document with another one.
- 4Read the formatted result below, then copy it to the clipboard or download it as a .json file.
- 5If the document is invalid, read the error: it names the line and column of the first problem.
Questions
- Is my JSON sent to a server?
- No. The parsing and formatting happen in JavaScript inside your browser tab. There is no upload step, no API call and nothing stored, which is why the tool keeps working if you disconnect from the network.
- How large a document can it handle?
- Comfortably a few megabytes. The limit is your device's memory rather than any rule we impose. Very large files — tens of megabytes — will make the browser pause while it reparses, so a text editor is a better tool at that size.
- Why does it say my JSON is invalid when it looks fine?
- The usual causes are a trailing comma before a closing brace or bracket, single quotes instead of double quotes, an unquoted key, or a stray non-breaking space pasted in from a document. The error message names the line and column, which almost always points straight at one of those.
- What does sorting keys actually change?
- Only the order the keys are printed in — the data is identical, since JSON objects are unordered by definition. It exists to make diffs meaningful when two systems emit the same object with the fields in different sequences.
- Can I format JSON with comments or trailing commas?
- Not currently. Those belong to JSON5 and JSONC rather than JSON proper, and this tool validates against the strict specification so that what it accepts is what a real parser will accept.
