data tool

JSON formatter

Paste JSON and it is checked as you type. The tree on the right shows the shape, the strip on top gives the verdict, and when it breaks you get the line, the column, the offending character under a caret and a jump button that puts your cursor on it.

Runs on your device. Nothing is uploaded.

Loading the tool…

How to use it

  1. 1

    Paste the JSON

    Nothing to press. The verdict strip, the tree and the size report all update as you type.

  2. 2

    Read the verdict

    Valid, valid with warnings, or not valid. Warnings are the quiet problems: a duplicate key whose first value is about to be thrown away, or a number too big to survive a round trip.

  3. 3

    Fix any error where it is

    The strip names the line and column, prints that line with a caret under the offending character, and explains what a JSON parser expected. Jump to line puts your cursor there.

  4. 4

    Explore the shape

    Every object and array in the tree is a button. Expand what you need, collapse the rest, or type in the find box to pull up only the branches that mention a key or a value.

  5. 5

    Format, or convert

    Format rewrites the box at your chosen indent. Advanced options minify, sort keys, drop nulls, and convert to YAML, CSV, JSON Lines, a query string or a TypeScript type.

Duplicate keys destroy data silently

JSON allows an object to name the same key twice. The specification says names should be unique but does not require it, and every browser resolves the conflict the same way: the last value wins and the earlier one disappears. A formatter built on the browser's own parser will hand you back a document with less in it than you pasted and say nothing. This one flags both lines, names the key and tells you which value survives, because it uses its own parser rather than the browser's.

Errors that say what went wrong

Browsers disagree about parse errors, and Chrome only added line and column numbers to some of them in late 2023. For a generic unexpected token it still returns a message with no position at all, which is why so many tools show you a wall of text and no location. This tool never asks the browser. It reads the document itself and always has a line, a column and an explanation in words: a trailing comma, a single quote, a comment, a curly quote pasted out of a word processor, or an invisible byte order mark at the top of the file.

Numbers that do not survive the trip

JavaScript holds every number as a double, so an integer above nine quadrillion loses its tail. A Mongo object id, a snowflake id or a Java long pasted into any browser based formatter comes back as a different number, and a value like 1e400 comes back as null. Both are flagged here with the original text and what it turns into, so you can move the value into a string before it reaches production rather than after.

Nothing leaves the page

The document you paste is parsed, drawn and converted entirely in this tab. There is no upload, no share link and no account, and you can confirm it by opening the network tab and typing. That matters more than it sounds: the well known online JSON viewers store your document on a server to give it a shareable URL, which is a problem the moment the payload came from work.

Limits

  • The tree draws the first 600 rows at a time. Collapse a branch or use the find box to narrow a very large document.
  • The find box is a plain search over keys and values, not JSONPath and not jq.
  • Very large files, past a few megabytes, will make the page pause while it parses them.
  • Numbers are read as JavaScript numbers, which is what every browser does. Anything past nine quadrillion is flagged rather than silently changed behind your back.

What it does not do

  • It does not repair broken JSON for you.
  • It does not validate against a JSON Schema.
  • It does not diff two documents. The text diff tool does that.

Questions people ask

Is my JSON sent anywhere?

No. Parsing, the tree, the error checking and every conversion run in this page. No network request is made after the page loads, which you can watch for yourself in the network tab of your developer tools. Nothing is stored either, so refreshing clears the box for good.

Why does it warn me about duplicate keys?

Because a duplicate silently costs you data. JSON permits the same key twice, and browsers keep only the last value, so formatting the document quietly deletes the earlier one. The warning names the key, gives you both line numbers and says the last value is the one that survives, so you can decide which was right.

Why does my file fail on a trailing comma?

Because JSON does not allow one. An array written as [1, 2, 3,] is valid JavaScript and invalid JSON, and the same goes for a comma after the last key in an object. It is the single most common failure, usually from copying a literal out of a code file. Remove the comma and it parses.

Can I use comments in JSON?

No. The format has no comment syntax, so a line beginning with two slashes or a block wrapped in slash star makes the file invalid. If a config file needs explanation, the usual workarounds are a key named underscore comment, or a format built for people to edit such as YAML or TOML.

Will it change my numbers?

Formatting round trips through a JavaScript number, so 1.50 becomes 1.5. Integers past about nine quadrillion cannot be held exactly and come back altered, and anything past the largest double becomes null. Both cases are flagged with the original digits, and identifiers that long belong in a string in the first place.

What does the find box search?

Key names and scalar values, as plain text, case insensitive. Matching branches open automatically and everything else is hidden, so you can pull one field out of a deep document without expanding it by hand. It is a search, not a query language, so it will not filter or reshape the data the way jq does.

Can it check my JSON against a schema?

No. It checks that the syntax is valid JSON and warns about the traps that parse but lose data. Whether the shape matches what a particular system expects is a different job that needs the schema itself. The TypeScript type in Advanced options is the nearest thing: it describes the shape you actually have.

It says my file is not JSON but every line looks fine

That is usually JSON Lines, one document per line, which many logging and export pipelines produce. The error offers to wrap the lines into a single array when every one of them parses on its own. Advanced options can also convert a valid array back to JSON Lines.

Turn this data into a written document

Take what you made here into documents.

Create a document with OneCraft

Related tools

Sources

Written and checked by the OneCraft team. Last checked .