JSON formatter and validator

Paste JSON below to format it, minify it or check it. If it is invalid, you get the line and column of the first error, and nothing leaves your browser.

runs in your browser · nothing uploaded

loading tool…

How to use it

  1. Paste your JSON into the input box, or type it.
  2. Pick an indent (2 spaces, 4 spaces or tabs) and press Format. Press Minify to strip all whitespace instead.
  3. If the JSON is invalid, the error message shows the line and column. Fix that spot and format again.
  4. Copy the result with the Copy button.

What counts as valid JSON

JSON is defined by RFC 8259. It is stricter than JavaScript object syntax, which is why code that works in a .js file often fails as JSON.

The usual culprits: keys must be in double quotes, strings must use double quotes rather than single, there can be no trailing comma after the last item, and comments are not allowed. The values NaN, Infinity and undefined do not exist in JSON either.

Sort keys for clean diffs

Tick "Sort keys" to order every object's keys alphabetically, at every depth. Two JSON files with the same data then format to the same text, so a diff shows only real changes. Arrays keep their order, because order in an array is data.

Large numbers

This tool parses with the browser's JSON.parse, which stores numbers as 64-bit floats. Integers above 9,007,199,254,740,991 (2^53 - 1), such as some database IDs, lose precision when reformatted. If your JSON carries IDs that large, keep them as strings.

Questions

Is what I paste sent to a server?

No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is uploaded, logged or stored by us, so it is safe to use with real data.

Why does it say "Unexpected token"?

The parser hit a character it did not expect at that position. Most often it is a single-quoted string, an unquoted key, a trailing comma or a comment. Go to the line and column shown and look just before it.

Can it fix my JSON automatically?

No, on purpose. Guessing what broken JSON meant can silently change your data. The tool points to the first error so you decide the fix.

Is there a size limit?

Only your browser's memory. Files of several megabytes format in well under a second on a normal laptop.

// built by horizech
Need the data in a spreadsheet? Studio converts a JSON file to CSV.
JSON to CSV on Horizech Studio ↗