Skip to content
Kalio
Developer

JSON formatter

Format, validate and minify JSON with precise error locations, optional key sorting and a structural summary of what the document contains.

Ready · runs on your device

Nothing is uploaded. This tool runs entirely inside your browser tab. Your files and figures stay on your device - we never receive them, so we cannot read, store or lose them.

What the validator checks

JSON is a deliberately small format, and its strictness is the source of most errors people hit. Valid JSON allows:

  • Double-quoted strings only - never single quotes
  • Double-quoted keys - never bare identifiers
  • No trailing commas anywhere
  • No comments of any kind
  • Numbers in decimal or exponent form - no leading +, no hex, no Infinity or NaN
  • Exactly these literals: true, false, null

When parsing fails, this tool converts the engine’s character offset into a line and column so you can navigate straight to the problem, rather than counting characters.

The most common errors

{
  "name": "example",
  "tags": ["a", "b",],
}

Two trailing commas - after "b" and after the tags array. Both are legal in modern JavaScript and neither is legal in JSON. This single mistake accounts for a large share of parse failures.

{
  'name': 'example'
}

Single quotes. Valid JavaScript, invalid JSON.

{
  name: "example"
}

An unquoted key. Again valid as a JS object literal, invalid as JSON.

The precision problem

This one bites in production. JSON numbers are parsed into JavaScript doubles, which represent integers exactly only up to 2⁵³ − 1 (9,007,199,254,740,991). A 64-bit ID such as 9007199254740993 will silently round.

If your API returns large integer identifiers - Twitter/X snowflake IDs, Discord IDs, database bigints - they must be transmitted as strings to survive a round trip through any JavaScript JSON parser. This is not a bug in the formatter; it is a property of the format meeting the language.

Sorting keys

JSON objects are formally unordered, so sorting keys changes nothing semantically. It is useful for two things: comparing two documents that contain the same data in different orders, and producing a canonical form so that a diff or a checksum is stable.

Arrays are never reordered, because array order is meaningful.

The structure summary

Alongside the formatted output you get a count of keys, objects, arrays and maximum nesting depth. Depth is the number worth watching. Anything beyond four or five levels is usually a sign that a structure has grown by accretion, and it is where both human readers and automated parsers start making mistakes.

Formatting conventions

Two-space indentation is the default and dominates the JavaScript ecosystem. Four spaces is common in Python and Java projects. Tabs are rarer but respect a reader’s own width preference. None of it affects the parsed result - pick whatever your team already uses and stay consistent.

Common questions

Is it safe to paste production data here?

The parsing happens entirely in this page - there is no request carrying your JSON anywhere, which you can confirm in your browser's network panel. That said, treat any browser tab as a place secrets can leak through extensions or screen sharing. For genuinely sensitive payloads, redact credentials first as a matter of habit.

Why does my JSON fail to parse when it looks fine?

The three usual causes are a trailing comma after the last element, single quotes instead of double quotes, and unquoted keys. All three are valid JavaScript object syntax and none are valid JSON. Comments are also rejected - JSON has no comment syntax, despite how often people try.

Does formatting change my data?

Beautifying and minifying change only whitespace. Sorting keys reorders object properties, which is semantically irrelevant in JSON but will alter a byte-for-byte comparison or a hash. Numbers are re-serialised by the JavaScript engine, so 1.0 becomes 1 and very large integers beyond 2⁵³ lose precision - a real hazard with 64-bit IDs from APIs.

What is the point of minifying?

Removing whitespace from a formatted document typically cuts 15–30% of its size. Over HTTP with gzip or brotli the saving mostly disappears, since compression handles repeated whitespace well. It matters most for storage, for payload size limits, and for embedding JSON in another format.

Last reviewed