Skip to content
CHARTOVANA

JSON Formatter

Format, validate and minify JSON as you type. Errors show the exact line and column with a plain-English fix, and your data never leaves your browser.
Runs in your browser. Nothing is uploaded.

How to use the JSON Formatter

  1. Paste or type JSON into the input. It is checked and formatted instantly.
  2. Choose Beautify for readable output with 2 spaces, 4 spaces or tabs, or Minify to remove all whitespace. Tick Sort keys to order object keys alphabetically.
  3. If the JSON is invalid, read the message under the editors and use Show in input to jump to the problem.
  4. Copy the result or download it as a .json file.

Examples

Minified input

{"id":7,"name":"Ada","roles":["admin","editor"],"active":true}

Beautified with 2 spaces

{
  "id": 7,
  "name": "Ada",
  "roles": [
    "admin",
    "editor"
  ],
  "active": true
}

A common error: {"a": 1, "b": 2,} is reported as “Trailing commas are not allowed” at line 1, column 16, which is the position of the extra comma.

JSON basics and common errors

JSON (JavaScript Object Notation) is a text format for structured data, used by most web APIs and many configuration files. A JSON document is one value: an object in { }, an array in [ ], a string in double quotes, a number, true, false or null.

The rules that trip people up

  • Double quotes only. Keys and strings must use ", never '. Keys must always be quoted.
  • No trailing commas after the last item in an object or array.
  • No comments. // and /* */ are not part of JSON. Formats such as JSONC and JSON5 allow them, but standard parsers reject them.
  • Lowercase literals. true, false and null are lowercase. undefined, NaN and Infinity don’t exist in JSON.
  • Strict numbers. No leading zeros (07), no leading or trailing decimal point (.5, 5.) and no hex.
  • Escaped special characters. Line breaks and tabs inside a string must be written as \n and \t.

Your data is never changed

Many formatters run JSON through the browser’s own parser and print it again. That rounds large numbers, so an ID like 12345678901234567890 becomes 12345678901234567000, and it silently drops duplicate keys. This formatter keeps every number, string and key exactly as written and only changes the whitespace, plus the key order if you choose Sort keys. Duplicate keys are kept and flagged, because most programs reading the file will keep only the last one.

Frequently asked questions

Is my JSON uploaded to a server?

No. Parsing and formatting run in your browser with JavaScript, so API responses, tokens or customer data you paste stay on your device. Nothing is stored after you close the page.

What is the difference between beautify and minify?

Beautify adds line breaks and indentation so people can read the structure. Minify removes every unnecessary space and line break, which makes the file smaller for sending over a network. Both contain exactly the same data.

Should I use 2 spaces, 4 spaces or tabs?

It doesn’t affect the data. Two spaces is the most common choice for JSON and is the default in JavaScript’s JSON.stringify examples and many style guides. Follow whatever your project already uses.

How large a file can it handle?

Files of several megabytes format in well under a second on a modern computer. Very large files of 50 MB or more may be slow, because the text area itself has to display them.

Why does the error point to a different line than I expected?

A parser reports the first place where the text stops making sense, which can be just after the real mistake. A missing comma, for example, is reported at the start of the next item. Check the line shown and the one before it.

Does Sort keys change arrays?

No. Only the keys inside objects are sorted, at every level. Arrays keep their order, because in JSON the order of array items is meaningful.

Last updated