Developer Tools

JSON Viewer and Formatter

This tool indents JSON so it can be read, validates it so you can find the mistake, and warns about a failure mode almost every other viewer hides: JavaScript cannot represent integers beyond about nine quadrillion, so a large database id is silently rounded on the way in and displayed as a different number entirely.

Runs entirely in your browser — nothing you paste is uploaded.

Indent

How to

How to use the JSON Viewer

  1. 1

    Paste your JSON

    Type, paste, or load a .json file. Validation runs as you type, so an error appears the moment it exists.

  2. 2

    Read any error precisely

    A failure reports the line and column and shows the line itself, rather than a bare message about an unexpected token.

  3. 3

    Format or minify

    Choose an indent for reading, or minify to the smallest valid form for transport. Keys can be sorted recursively to make two documents comparable.

  4. 4

    Check the warnings

    If the document contains integers beyond JavaScript's exact range, they are listed — a real problem when those values are database identifiers.

Examples

JSON Viewer examples

An oversized identifier

Input
{"id": 9007199254740993}
Output
Warning: 9007199254740993 cannot be represented exactly

Parsed as a JavaScript number, this becomes ...992. Every viewer built on JSON.parse displays the wrong value silently; here it is flagged before you copy it somewhere that matters.

A trailing comma

Input
{"a": 1,}
Output
Error at line 1, column 8

JSON forbids trailing commas even though JavaScript allows them. The location makes it findable in a document of a few thousand lines.

Sorting keys to compare two files

Input
{"b":1,"a":2}
Output
{"a":2,"b":1}

Sorting recursively puts two documents into the same shape, so a diff shows genuine differences rather than every reordered key.

Why use it

What the JSON Viewer gives you

Errors you can act on

A line, a column and the text of the offending line, instead of a message that tells you only that something is wrong somewhere.

Catches silent number corruption

Large integers are detected in the raw text before parsing, which is the only point at which the information still exists.

Makes documents comparable

Recursive key sorting turns two structurally identical payloads into two identical files, which is what makes a diff useful.

Nothing is uploaded

API responses pasted into a viewer routinely contain tokens and personal data. None of it leaves your browser.

Good to know

JSON Viewer limitations

  • Large integers are reported but not repaired, since fixing them requires changing the type — usually to a string — which only the producing system can decide.
  • JSON with comments or trailing commas is invalid by the standard and is reported as an error rather than silently accepted.
  • Very large documents are held in memory twice, as text and as a parsed value, so a file beyond tens of megabytes may struggle.
  • Duplicate keys are resolved by the parser keeping the last one, which is standard behaviour but means the loss is invisible.

Summary

JSON Viewer in short

  • Errors are reported with a line and column, not just a message.
  • Integers beyond 2^53 are silently corrupted by every JSON parser in JavaScript; this one warns you.
  • Sorting keys recursively makes two documents genuinely comparable.
  • Comments and trailing commas are not valid JSON, however common they are.
  • Everything runs in your browser.

FAQ

JSON Viewer questions

Why would a number change when I format my JSON?

JavaScript stores all numbers as doubles, which represent integers exactly only up to 2^53 — about nine quadrillion. A larger id is rounded to the nearest representable value on parsing, so it comes out as a different number with no error raised.

How do I fix an oversized number?

The producing system needs to send it as a string. There is no way to recover the original value once it has been parsed, which is why this tool inspects the raw text before parsing rather than after.

Why is my JSON with comments rejected?

The JSON specification has no comments. Several tools accept them as an extension — JSON5 and JSONC exist for exactly this — but a document containing them is not JSON and will be rejected by any strict parser, including this one.

Why can I not leave a trailing comma?

JavaScript object literals allow one; JSON does not. It is the single most common validation error, because the two syntaxes look identical until a parser disagrees.

What happens if the same key appears twice?

The parser keeps the last one and discards the first, silently. The specification does not define the behaviour, so different languages resolve it differently — which makes duplicate keys a genuine portability problem.

When is sorting keys useful?

When comparing two documents. Key order carries no meaning in JSON, so two equivalent payloads can differ textually in every line. Sorting both puts them in the same shape and leaves only real differences.

How much smaller is minified JSON?

Formatted JSON is often 20 to 40 percent whitespace, so minifying saves roughly that. Over the wire the difference is much smaller, since gzip compresses repeated indentation very efficiently.

How large a file can it handle?

A few megabytes is comfortable. The document is held both as text and as a parsed structure, so memory use is roughly double the file size and a very large export may be slow.

Is the JSON I paste sent anywhere?

No. Parsing and formatting happen in this page. This matters more than for most tools, since the JSON people paste into a viewer is usually a live API response complete with auth tokens and customer records.

Discover

Related developer tools