JSON Formatter & Validator
Free JSON formatter and validator: beautify JSON with 2 spaces, 4 spaces or tabs, find errors by line and column, and keep big numbers exact. Runs in your browser.
How to use JSON Formatter
- 1Paste your JSON, type it, or open a .json file.
- 2Pick 2 spaces, 4 spaces or Tab. The formatted result updates as you type; switch Mode to Minify, Sort keys, Tree or Escape for other jobs.
- 3Copy the result, download formatted.json, or use it as the next input.
What makes it better
- Validates while it formats and points to the line and column of the first error
- Friendly hints for trailing commas, comments, single quotes and unquoted keys
- Numbers and strings are kept verbatim, so IDs beyond 2^53 stay exact
- Status line with key count, nesting depth and size
- Switch to Minify, Sort keys, Tree or Escape without leaving the page; your input stays put
About JSON Formatter
This JSON formatter indents your JSON so it is easy to read and checks that it is valid at the same time. When something is wrong it names the line and column, shows the offending line with a caret and explains common mistakes such as trailing commas, comments and single quotes. Numbers and strings are copied exactly as written, so a long ID like 12345678901234567890 is not rounded.
Common uses
- Read a minified API response that arrived as one long line.
- Find the missing comma that makes a config file fail to load.
- Tidy JSON before pasting it into documentation, a ticket or a pull request.
- Check a payload is strictly valid JSON, not just JavaScript-like, before sending it to a server.
Example
Input
{"name":"Ada Lovelace","born":1815,"tags":["math","code"],"address":{"city":"London","zip":null},"id":12345678901234567890}Result
{
"name": "Ada Lovelace",
"born": 1815,
"tags": [
"math",
"code"
],
"address": {
"city": "London",
"zip": null
},
"id": 12345678901234567890
}Good to know
- Only strict JSON is accepted. Comments, trailing commas, single quotes and unquoted keys are reported as errors instead of being silently fixed.
- A leading byte-order mark (BOM) is ignored. If the same key appears twice in an object, both are kept in the output.
- Formatting never changes values, but it does change whitespace, so do not format data that is signed or hashed byte for byte.
JSON Formatter FAQ
How do I format JSON online?
Paste the JSON into the input box and the indented version appears next to it straight away. Choose 2 spaces, 4 spaces or Tab to match the style your project uses, then copy or download the result.
Why does my JSON show an error about a trailing comma?
JavaScript allows a comma after the last item in an object or array, but the JSON standard does not. The error points at the closing bracket so you can delete the comma just before it.
Can I put comments in JSON?
No. Standard JSON has no comment syntax, so // and /* */ are reported as errors here. Remove them, or keep the notes in a separate field such as "_comment" if the consumer allows extra keys.
Does the formatter change my numbers?
No. Number literals are copied exactly as typed, so 1.10 stays 1.10 and 12345678901234567890 stays intact. Tools that parse and re-serialise with JavaScript would round that ID to 12345678901234567000.
How do I find the exact place where my JSON breaks?
Read the line and column in the red message, then look at the excerpt under it. The caret sits under the first character the parser could not accept, which is often one token after the real mistake, such as a missing comma on the previous line.