JSON Formatter & Validator

Paste JSON to beautify, validate or minify it. Errors are shown with their line and column, and common mistakes can be fixed in one click.

Your JSON is processed in your browser and never uploaded.

2 spaces
Formatted JSON

This JSON formatter and validator makes JSON readable, checks that it is valid, and minifies it when you need it small. Paste an API response, a config file or a log line and it is pretty-printed as you type. If the JSON is broken you see exactly where: the line, the column and a marker under the character that stopped the parser. Common mistakes copied from JavaScript or Python, such as trailing commas, comments and single quotes, can be fixed with one click.

How to Use the JSON Formatter

  1. Paste JSON or open a .json file.
  2. Choose Beautify or Minify. For Beautify, pick 2 spaces, 4 spaces or tabs; turn on Sort keys to order every object alphabetically.
  3. Read the status bar. It confirms valid JSON with the number of keys, how deeply it is nested and the size before and after, or points to the first error.
  4. Copy or download the result as a .json file.

Common JSON Errors and How to Fix Them

InvalidValidProblem
{"a": 1,}{"a": 1}Trailing comma after the last item
{name: "Ali"}{"name": "Ali"}Keys must be in double quotes
{'name': 'Ali'}{"name": "Ali"}Strings must use double quotes
{"a": 1 // note}{"a": 1}JSON has no comments
{"a": 1 "b": 2}{"a": 1, "b": 2}Missing comma between items
{"ok": True}{"ok": true}true, false and null are lowercase
{"n": NaN}{"n": null}NaN and Infinity are not allowed

Beautify or Minify?

Beautified JSON, with each value on its own line, is for reading, reviewing and committing to version control, where one changed value shows up as one changed line. Minified JSON removes every space and line break that is not inside a string. It is the same data in fewer bytes (the status bar shows how many), and suits request bodies, environment variables and anything stored in a single line. Both outputs are produced by the browser's own JSON.stringify, so numbers and escaped characters come out exactly as JavaScript would write them.

JSON Rules in Short

  • A value is an object {}, an array [], a string in double quotes, a number, true, false or null.
  • Numbers are plain decimals: no leading +, no leading zeros such as 007, no hex.
  • Inside strings, a double quote, backslash and control characters such as a line break must be escaped (\", \\, \n).
  • Duplicate keys are allowed by the syntax, but most parsers keep only the last one, so avoid them.

Related Tools

To open JSON data in Excel or Google Sheets, convert it with the JSON to CSV converter. Working on a front end? The HEX to OKLCH converter and contrast checker are in the same set of developer tools.

Frequently Asked Questions

How do I format JSON?

Paste it into the left box. The formatted version appears on the right as you type, indented with 2 spaces by default. Choose 4 spaces or tabs, or switch to Minify for the most compact form.

How do I know if my JSON is valid?

A green Valid JSON bar appears below the boxes when it parses. If it does not, a red bar shows the line and column of the first error, the line itself with a marker under the problem, and what the parser expected there.

What are the most common JSON errors?

A comma after the last item in an object or array, keys without double quotes, strings in single quotes, comments, and missing commas between items. JSON also does not allow NaN, Infinity, undefined or functions.

What does Fix automatically do?

It rewrites JavaScript-style JSON as standard JSON: it removes // and /* */ comments and trailing commas, changes single-quoted strings to double-quoted ones, puts double quotes around bare keys, and turns Python's True, False and None into true, false and null. The button only appears when that is enough to make the JSON valid. Text inside strings is never changed.

Does sorting keys change my data?

No. Objects in JSON have no meaningful key order, so sorting only changes how it reads. Arrays keep their order. Sorting is useful for comparing two JSON files or keeping config files tidy.

Is there a size limit?

There is no set limit. Files of a few megabytes format instantly; very large files depend on your device's memory, since everything happens in the browser.

Is my JSON uploaded or saved?

No. It is parsed by your browser and never leaves your device, so it is safe to paste API responses, tokens or customer data. Nothing is stored after you close the page.