JSON Formatter and Validator

Developer

Validate, pretty print, minify and sort keys. Client-side only.

Output
{ "employee": "Juan dela Cruz", "monthlySalary": 30000, "allowances": [ { "type": "transport", "amount": 2000 } ], "regular": true, "separatedOn": null }
Size161 B
Keys7
Depth3 levels

How to use

What it's for

Make JSON readable, squeeze it onto one line, or find exactly where it is broken. JSON is the text format apps and websites use to pass data around, written with curly brackets and quotes.

Before you start

Have the JSON you were given — by an app, a website, a developer or a file — ready to paste. It stays in your browser and is never uploaded.

  1. Paste your JSON

    Paste it into Document, replacing the sample that is there.

  2. Choose what to do with it

    Press Format to lay it out neatly over many lines, Minify to squeeze it onto one line to save space, or Validate just to check that it is correct.

  3. Set the layout, if formatting

    With Format, choose how far each level is pushed in under Indent; leave it on 2 spaces unless you were told otherwise. Turn on Sort keys to put the field names in A to Z order — the data itself does not change.

  4. Show the result and copy it

    Press Show the result to bring the answer into view; it has been updating as you type. Press Copy to take it.

  5. Fix any mistake it points to

    If the JSON is broken, a box under the document gives the line and column, prints that line, and puts a ^ under the exact character. Fix it in Document and the answer comes back.

Reading the result

  • Output: your JSON, laid out or squeezed. With Validate, it simply says Valid JSON.
  • Not valid JSON: shown instead when there is a mistake — read the message under the document.
  • Size, Keys and Depth: how big the document is, how many field names it holds, and how many levels deep it goes. With Minify, Saved shows how much smaller it got.

If it goes wrong

  • The commonest mistakes are a missing comma, an extra comma after the last item, and text in single quotes — JSON only accepts double quotes.
  • An error says JSON has no comments: remove the lines starting with // or the /* */ blocks. A file with comments is not JSON, whatever its name says.
  • A note says a name appears more than once in the same object: most apps quietly keep only the last one. Both are kept here, so delete the one you do not want.

What this is

Validate a document, pretty print it at the indent you want, minify it for the wire, or sort every object's keys so two versions of the same file can be compared.

The document is parsed here rather than handed to the browser's own JSON reader, for three reasons. The browser's parser does not tell you reliably WHERE an error is — the wording and the position differ between Chrome, Safari and Firefox — so it could not point at a line. It turns every number into a floating-point value, which rounds long ids and drops trailing zeroes, corrupting a document you only asked to tidy. And it silently discards duplicate property names, which is the exact kind of quiet wrongness worth catching.

Strings are the one thing rewritten rather than preserved: A becomes A. That changes the bytes but not the value, so nothing is lost — unlike a number, where the two really would differ.

Questions

Where exactly is my syntax error?

The page gives the line and the column, prints the offending line, and puts a caret under the character that broke it. Most JSON errors are a missing comma, a trailing comma or an unclosed brace, and all three are invisible until something points at them.

Why does it complain about a trailing comma?

Because JSON does not allow one, even though JavaScript, Python and most config formats do. This is the single most common JSON error. JSON5 and JSONC allow trailing commas and comments — if your file has either, it is not JSON, whatever the extension says.

Will formatting change my numbers?

No, and that is deliberate. Most formatters parse a number into a float and write the float back, which silently rounds a long id — 1234567890123456789 becomes 1234567890123456800 — and turns 1.0 into 1. This keeps every number exactly as you wrote it, digit for digit.

What is a duplicate key and why should I care?

JSON does not forbid the same property name twice in one object, and nearly every parser silently keeps the last one. So {"amount": 500, "amount": 50} is a valid document that quietly becomes 50. This finds them, tells you the line, and keeps both — a formatter should never be the thing that deleted a line of your data.

Does sorting keys change the meaning of my document?

No. Property order is not significant in JSON, so a sorted object is the same object. Array order IS significant and is never touched. Sorting is by character code rather than by locale, so the same file sorts the same way on every machine — a sorted file that still shows a diff would defeat the point.

Is my data uploaded anywhere?

No. The parser is JavaScript running in this tab, and no request carrying your document is ever made. That matters here more than on most pages, because the JSON people paste into a formatter is very often a real API response with real customer records in it.

What it checks

The three commonest errors
{"a": 1,}  — trailing comma
{a: 1}     — unquoted name
{'a': 1}   — single quotes

All three are legal JavaScript and none is legal JSON. Each is named for what it is rather than reported as an unexpected token.

Numbers are not touched
A 19-digit id, formatted
parse, then re-print …3456800
kept verbatim …3456789

A double holds about 15 significant digits. Anything longer — a Twitter id, a Snowflake, a bank reference — comes back wrong from a formatter that round-trips through a float.

What it measures
Size UTF-8 bytes, not characters
Depth nesting levels
Keys every property name, duplicates included

Keep going

Important

Documents are parsed strictly to RFC 8259. JSON5 and JSONC — comments, trailing commas, unquoted keys — are reported as errors rather than accepted. Nothing you type here is sent to our servers — the calculation runs entirely in your browser.