Developer tool

JSON Formatter and Validator

Format, minify, validate and explore JSON in your browser. Pinpoints errors by line and column, sorts keys, and shows a collapsible tree. Nothing is uploaded.

Free, no sign-up. Runs in your browser; nothing is uploaded.

JSON input

Options

Action
Indent

Result

View
Input size
176 B
Output size
289 B
Change
+64%
Status
Valid

How to use the json formatter and validator

Clean up JSON in three steps

  1. Paste your JSON, or upload a .json file. The result updates as you type.
  2. Choose Format for readable output (2 spaces, 4 spaces or tabs) or Minify to strip all whitespace for transport.
  3. Copy the result or download it as a file. The size cards show bytes before and after so you can see what minifying saves.

Reading an error

When the JSON is invalid, the tool shows the parser's message with the line and column, and prints the offending line with a caret under the problem. Use Jump to error to select that character in the input box. Most problems come from a few causes:

  • Trailing comma after the last item in an object or array.
  • Single quotes or unquoted keys, which are valid in JavaScript but not in JSON.
  • Missing comma between two items, usually reported on the line after the real mistake.
  • Comments such as // or /* */, which JSON does not allow.
  • Truncated data, reported as an unexpected end, often from a cut-off copy or response.

The reported position is where the parser noticed the problem, so also look at the line above.

Using the tree view

Switch to Tree to explore a large document. Each object shows its key count and each array its length. Values are coloured by type: strings, numbers, booleans and null. Click an arrow to expand or collapse a node, or click a key to copy its path, such as $.items[0].price, ready for code or a query tool. Big documents open with the first 2,000 nodes expanded and long lists load 100 items at a time.

Tips

  • Sort keys before comparing two configuration files in a diff tool.
  • Minify before embedding JSON in a script tag or sending it in a request body.
  • Numbers beyond 15 to 16 significant digits lose precision when parsed by JavaScript. Keep such IDs as strings.
  • Duplicate keys are allowed by the parser, but only the last value is kept.

Frequently asked questions

Why does my JSON say invalid when it works in JavaScript?

JSON is stricter than a JavaScript object literal. Keys must be in double quotes, strings must use double quotes, and trailing commas, comments, single quotes and values such as undefined or NaN are not allowed.

How are the line and column of an error worked out?

Browsers report where parsing stopped, in different formats. The tool reads whichever format your browser uses and converts it to a line and column. If the browser gives no position, the tool scans the text itself to find the first bad character.

Does sorting keys change the meaning of my data?

No for objects, because JSON object keys are unordered by definition. Array order is never changed. Sorting is useful for diffing two files or producing stable output.

Can it handle large files?

Yes, formatting is done by the built-in parser, which is fast. The tree view expands only the first 2,000 nodes and loads long lists 100 items at a time so the page stays responsive.

Is my JSON uploaded anywhere?

No. Parsing, formatting and the tree all run locally in your browser, so tokens, configs and customer data stay on your device.