BlueCheddar

JSON formatter and validator

This JSON formatter checks your JSON and lays it out as you type, with the exact line and column of any error. It runs in your browser, so your text stays on your device and is not saved.

Nothing is uploaded or saved. Formatting runs on this device.

How to format JSON

  1. Paste your JSON in the box, or open a .json file.
  2. Pick the indent, or None to minify it. Sort keys is optional.
  3. If it is not valid, read the line and column, then fix it or try the repair.
  4. Copy the result, or save it as a file.

Questions

Is my JSON uploaded or saved?

No. It is read in your browser and kept only until you close the page. This page has no save or share feature, so there is no link that could expose your data, and it writes nothing to your browser's storage. You can check this yourself. Browser extensions can still read any page, so turn off ones you don't trust.

Does it change long numbers?

No. An ordinary JavaScript number holds about 16 digits, so a tool built on JSON.parse turns 12345678901234567890 into 12345678901234567000. This page never turns your numbers into JavaScript numbers. It copies them as written and lists the ones another JavaScript program would change. Our tests compare the output with Python's json module, reading every number as text.

What happens with duplicate keys?

They are kept and listed. JSON.parse and most other readers keep only the last value of a repeated key and say nothing. Here both stay in the output, in their order, and the list gives each repeat's line, column and path.

What does the repair change?

Only a short list of mistakes: trailing and missing commas, comments, single and curly quotes, keys without quotes, Python's True, False and None, line breaks and tabs inside strings, numbers such as .5 and +1, and brackets missing at the end of a cut-off text. It runs only when you ask. It lists each change with its place, and your text in the box stays as it was. A missing comma or a cut-off end can have another cause, so read the list. If it finds anything else, it stops and changes nothing.

How large a file can it take?

Up to 50 MB on a computer. In our test, a 50 MB file with 631,673 numbers too long for JavaScript took 16 seconds in Chromium on a desktop computer, and the page's longest pause was 0.4 seconds, because the work runs in a worker. A 100 MB file did not finish within 3 minutes, so that size is refused. Above 200 KB, the result box shows the first 200 KB and the file you save has all of it, because browsers can freeze laying out a very large text box. Pasting very large text can freeze the box for the same reason, so open such text as a file. The 20 MB limit on a phone is an estimate, not a measurement.

Why does the column number differ from my editor's?

It may not, but some editors count differently. This page counts each character as one, including an emoji, and a tab as one, starting from 1. Lines end only at a line feed.

Can it open a tree view, or query with JSONPath?

No. It formats, minifies, sorts, validates and repairs. Keeping out a tree view keeps very large files workable, as it draws no element for each value.