Skip to content

JSON formatter & validator

Beautify, validate and minify JSON, with errors pinpointed by line.

Updated

Mode

How to format JSON

  1. Paste your JSON into the input box, open a .json file, or try the example.
  2. Choose Format for readable, indented output or Minify for the smallest size.
  3. Pick an indent and, if you want, sort the keys alphabetically.
  4. Copy the result or download it as a file.

Common JSON errors

MistakeInvalidValid
Trailing comma{"a": 1,}{"a": 1}
Single quotes{'a': 'b'}{"a": "b"}
Unquoted key{a: 1}{"a": 1}
Comments{"a": 1 // note}{"a": 1}
Special values{"a": undefined}{"a": null}

Format or minify?

Formatted JSON is for people: each value on its own line, indented to show structure, easy to read in a diff. Minified JSON is for machines: all whitespace removed, so it's smaller to store and send. Both contain exactly the same data.

Common uses

  • An API response on one line. Responses from APIs and logs often arrive as one long line. Paste it in and Format turns it into indented, readable JSON.
  • A config file that won't load. When an app refuses to start because of its JSON config, paste the file in to see what's wrong and where, then fix it in your editor.
  • Comparing two JSON exports. Turn on Sort keys and format both versions, then compare them with the text diff tool to see what really changed.
  • JSON for a single-line field. Minify removes all whitespace, which is handy for pasting JSON into an environment variable or a one-line config setting.

Questions

How do I find the error in my JSON?

Paste it in. If it isn't valid, the tool tells you what went wrong and the exact line and column, such as a trailing comma or a missing quote.

Why is my JSON invalid when it works in JavaScript?

JSON is stricter than JavaScript: keys and strings need double quotes, trailing commas aren't allowed, and comments aren't part of the format. Remove those and it will parse.

What does “Sort keys” do?

It orders every object's keys alphabetically, at every level, which makes two versions of the same data much easier to compare. Array order is never changed.

Will very large numbers stay exact?

Whole numbers beyond 9,007,199,254,740,991 (2⁵³ − 1) can lose precision when formatted, because standard JSON parsing uses 64-bit floating-point numbers. Keep IDs that large as strings.