Check whether JSON is valid and find the exact error.
JSON Formatter
Format, indent and beautify JSON.
Runs in your browserProcessed locally. Your input never leaves your device.
Details
About this tool
Paste JSON and get it back correctly indented, as you type. Choose two spaces, four, tabs, or no whitespace at all to minify, and optionally sort every object's keys alphabetically.
A minified API response is one enormous line, and no amount of squinting turns it into something a person can follow. Indenting it puts the structure back: one key per line, nesting shown by depth, and arrays laid out so you can count them. That is the whole job, and it is the fastest way to answer questions like which field is null, how deep the nesting goes, or whether the thing you expected to be an object is actually an array with one object in it.
Sorting keys is for comparing. Two JSON documents that differ only in key order are the same document, but a plain text diff will paint them as entirely different. Sorting both first makes the real differences the only differences - useful for configuration files, API snapshots and anything checked into version control, where a stable order also keeps future diffs small.
Minifying does the opposite and is worth doing before a payload goes over the wire: whitespace in JSON carries no meaning, so removing it costs nothing and can take a noticeable slice off a large response. Formatting never changes the data - the same values, the same order unless you asked for sorting, and numbers written exactly as they were.
Invalid input is reported with the line and column where parsing stopped, so the formatter doubles as a validator. Everything runs in your browser, which matters more than for most tools here, because the JSON people paste into a formatter is usually a real API response with real customer data in it.
Keep going
Related tools
- Runs in your browserDeveloper
-
Convert text to Base64 and back.
Runs in your browserDeveloper -
Inspect the header and payload of a JSON Web Token.
Runs in your browserDeveloper
Good to know
Questions people actually ask
- Is my JSON uploaded to a server?
- No. The formatting is JavaScript running in your browser, so the document never leaves your device. That matters here in particular: the JSON people reach for a formatter with is usually a live API response with real data in it.
- Why does it say my JSON is invalid?
- Usually one of four things: a trailing comma after the last item, single quotes instead of double, an unquoted key, or a comment. All four are legal in JavaScript and none are legal in JSON. The error names the line and column where the parser stopped - which, for an unclosed brace or string, is often below where the mistake actually is.
- What does sorting the keys do?
- Reorders every object's keys alphabetically, at every level. Its purpose is comparison: two documents identical apart from key order look completely different to a text diff, and sorting both first leaves only the real differences. It changes the order, never the data.
- Does formatting change my data?
- No. Whitespace between tokens has no meaning in JSON, so adding or removing it cannot alter the document. Values, types and array order are untouched, and numbers are written back exactly as they appeared rather than being reformatted.
- Can it handle a very large file?
- Up to the point where your browser can hold the whole document in memory twice, which is fine for the API responses and configuration files this is meant for. A multi-hundred-megabyte export is a job for a streaming parser such as jq on your own machine, not for any web page.