Skip to content
toolsdocks

Minify JSON, or format and validate it

Paste JSON or JSON Lines to format or minify it, see exactly where a syntax error is, and explore the structure as a tree.

Runs on your device
Loading tool…

How to use

  1. Paste JSON, open a file, or load the sample. Set Input to JSON or JSON Lines, depending on whether you have one document or one object per line.
  2. Choose the Output action: Format to make it readable or Minify to strip whitespace.
  3. Pick an Indent of 2 spaces, 4 spaces or Tab, and tick Sort keys A to Z if you want a stable order for comparing files.
  4. If the input is invalid, read the message and press the Show line link to jump to the exact line and column.
  5. Tick Remove comments and trailing commas to repair those two common mistakes. Any other error is still reported.
  6. Switch the Output view between Text and Tree. In the tree, hover a row to see its JSON Pointer, and paste a JSON Schema to validate against it.

Worked example

{"a":1,} reports “Expected double-quoted property name at line 1, column 8”, which points at the trailing comma.

Supported formats and limits

InputJSON, JSON Lines
OutputJSON
EngineLossless JSON parser with error positions; tree view; validator for a documented JSON Schema keyword subset

Tips for best results

  • The usual syntax errors are single quotes instead of double quotes, keys without quotes, a comma after the last item, and a raw line break inside a string.
  • Sort the keys of two API responses before running them through the text compare tool, and the real changes stand out from reordering noise.
  • Integers beyond 9,007,199,254,740,991 lose precision in JavaScript. The tool counts these unsafe integers, which matters for IDs from services such as social media APIs.
  • A duplicate key is legal syntax but most parsers keep only the last value, so the tool flags each one with its line number.
  • Use JSON Lines mode for log exports and data dumps where each line is its own record.

Limits

  • Comments and trailing commas are not valid JSON; use Repair to remove them.
  • Schema checks cover type, properties, required, items, enum, const, minimum, maximum, minLength, maxLength, pattern and additionalProperties; other keywords are listed as ignored.
  • Large documents are processed in a background worker, so output can take a moment to appear and you can cancel the run. Formatting does not change your numbers.

Questions

How do I minify JSON?

Paste the JSON and choose Minify. All whitespace between tokens is removed without changing any value, numbers included, and the result can be copied or downloaded.

How do I find a JSON syntax error?

Paste the JSON and the error is shown with its line and column, for example a trailing comma in {"a":1,} at line 1, column 8. Comments and trailing commas can be removed with Repair.

Will formatting change my numbers?

No. Numbers and strings are kept exactly as written, so a big integer such as 12345678901234567890 keeps all its digits and key order is preserved unless you sort keys.

Does it validate against a JSON Schema?

It checks a documented subset of keywords (type, properties, required, items, enum, const, ranges, lengths, pattern and additionalProperties) and points to the failing value. Keywords outside the subset are listed as ignored, so it is not a full JSON Schema validator.

Guides

Privacy

Runs on your device. Files and text are processed in this browser tab and are not uploaded.

See the privacy policy for how toolsdocks handles data.