mygems

Format and validate JSON

Valid JSON, pretty. Broken JSON, located and mostly fixed.

  • Errors by line and column
  • Fix in one click
  • Big numbers kept exact
  • Nothing uploaded

1.Paste JSON, or open a file

JSON, JSONC or plain text. Drag it here, or choose a file.

2.Format, minify or fix it

Fix removes comments and trailing commas, converts single quotes and quotes bare keys. Nothing else is guessed at.

Why it exists

Most JSON that fails to parse was written by a person, and people write JSON the way they write JavaScript: a comment here, a trailing comma there, single quotes, a key without quotes. A validator that answers "Unexpected token at position 4031" is technically right and practically useless. This one says which line and column, in words, and for those four habits it offers to undo them rather than asking you to hunt.

What it does

  • Formats with two spaces, four spaces or tabs, or minifies to the smallest file.
  • Validates strictly, and names the problem in words with its line and column.
  • Puts the cursor on the problem with one click, so you can see it in context.
  • Fixes comments, trailing commas, single-quoted strings and unquoted keys, and says how many of each it changed.
  • Keeps numbers exactly as written, so a 20-digit ID is not rounded on the way through.

What Fix will not do

It will not guess. A missing comma between two values, an unclosed bracket or a stray character could each be repaired in more than one way, and a formatter that picks one silently can change what the document means. Those are reported with their line and column, and the decision stays yours.

Questions

Is my JSON sent anywhere?
No. It is parsed by code running inside the page. There is no server behind this tool, and nothing you paste or open leaves the tab.
Why does it keep my long numbers when other formatters change them?
Most formatters parse JSON into JavaScript numbers, which hold about 15 significant digits, so 12345678901234567890 comes back as 12345678901234567000. This keeps every number as the text it was written as, and only the whitespace around it changes.
Does it support JSON5 or JSONC?
It reads the parts of them people use most, comments, trailing commas, single quotes and unquoted keys, and Fix turns them into standard JSON. It always writes standard JSON.
How large a file can it handle?
Tens of megabytes on a desktop browser. Past 2 MB the text is no longer shown in the box, so the page stays responsive, but formatting and fixing still work on the whole file.