JSON formatter and validator

Pretty-print JSON with indentation, minify it to one line or browse it as a collapsible tree. Syntax errors are shown with the line, column and the text around them.

How to use

  1. Paste your JSON into "JSON input".
  2. Choose an indent (2 spaces, 4 spaces or tab) and press "Format". Press "Minify" for a single line, or "Validate only" to just check it.
  3. Press "Tree view" to browse objects and arrays as a collapsible tree. "Expand all" and "Collapse all" switch every level at once.
  4. If there is an error, the line, column and nearby text are shown. Fix it and press the button again.
  5. Copy the result or download it as a .json file.

Notes and limits

  • Input up to 5 MB. Nesting up to 1,000 levels.
  • Standard JSON (RFC 8259) only. Comments, trailing commas, single quotes, NaN and Infinity are reported as errors.
  • Duplicate keys are not errors: they are kept as written and reported as a warning.
  • The tree view handles JSON with up to 20,000 values. Use Format for larger documents.
  • A leading BOM is removed. Output uses LF line endings.
  • Nothing you enter is saved. It is gone when you close the page.

How it works

Instead of JSON.parse, a small scanner reads the text character by character. Error messages and positions are therefore the same in every browser.

Strings and numbers are copied exactly as written. Large integers above 2^53 keep every digit, 1.0 stays 1.0, 1e400 is not turned into null, and escapes such as \u0041 are kept. Only whitespace and line breaks change.

When a key appears more than once in the same object, the key name, its location (for example $.items[0]) and the line and column are listed. Most programs keep only the last value.

The tree view is built from the same scan, so values are shown exactly as written (large integers keep every digit). Only key names are shown with their escapes decoded.

After minifying, the size before and after (UTF-8 bytes) is shown.

FAQ

Is my JSON sent anywhere?

No. Formatting and validation run entirely in your browser. Nothing is sent to our server.

Can large numbers lose precision?

No. Numbers are output exactly as you wrote them, so a value like 12345678901234567890 stays unchanged, in the tree view too.

Does it accept JSON with comments (JSONC)?

No. A comment is reported as an error at its position. Remove comments before formatting.

How are columns counted?

The first character of a line is column 1. Each character, including an emoji or a tab, counts as one column.

Last updated: