JSON Formatter and Validator

Free JSON formatter and validator: beautify or minify JSON, sort keys and find errors by line and column. Runs in your browser — data never leaves it.

✓ Free🔒 Private⚡ No sign-up
Drop a .json file here or click to choose — or paste below

🔒 Runs entirely in your browser. Your files are never uploaded.

</> Add to your site

Embed this tool on your website for free: copy the code and paste it into your page's HTML. Everything runs in your visitors' browsers; files are not uploaded.

Preview ↗

What this JSON formatter does

Paste JSON (or drop a .json file) and press Format / Validate. The tool:

  • checks that the text is valid JSON and, if not, shows the line and column where parsing failed and puts the cursor there;
  • beautifies it with 2 spaces, 4 spaces or tabs so nested objects and arrays are easy to read;
  • minifies it into a single line with no unnecessary whitespace;
  • optionally sorts object keys alphabetically at every level, which makes two JSON documents much easier to compare;
  • reports how many keys the document has and how deeply it is nested.

Copy the result with one click or download it as a .json file.

Private by design

Many online formatters send what you paste to their server. This one does not: everything happens with your browser's built-in JSON.parse and JSON.stringify. API responses with tokens, customer records or internal configuration never leave your device, and the page keeps working offline once loaded.

Common reasons JSON is invalid

JSON looks like JavaScript but is stricter. These are the mistakes that cause most errors:

  1. Trailing commas — {"a": 1,} is valid JavaScript but invalid JSON.
  2. Single quotes — keys and strings must use double quotes: {"name": "Ada"}, not {'name': 'Ada'}.
  3. Unquoted keys — {name: "Ada"} must be {"name": "Ada"}.
  4. Comments — // and /* */ are not allowed in JSON.
  5. Special values — undefined, NaN and Infinity do not exist in JSON; use null or a string.
  6. Unescaped characters — a line break or a double quote inside a string must be written as \n or \".

When the tool reports an error position, look at that spot and the character just before it; a missing comma usually shows up as an error at the start of the next value.

Example

Input: {"user":{"id":7,"roles":["admin","editor"]},"active":true}

Formatted with 2 spaces, the same data becomes a readable block where each key sits on its own line and the roles array is indented under user. Minify turns it back into the original single line.

Limitations

Numbers are handled as standard JavaScript numbers, so integers larger than 9,007,199,254,740,991 can lose precision when reformatted; store such IDs as strings. Duplicate keys are allowed by the parser, but only the last value is kept. Files up to 20 MB are accepted; very large documents may take a moment on slower devices.

Frequently asked questions

Is my JSON uploaded to a server?

No. Formatting and validation use your browser's built-in JSON parser. Nothing is sent anywhere, so it is safe for API responses, configs or data that contain private information.

How do I find the error in invalid JSON?

Press Format / Validate. If the JSON is invalid, the tool reports the line and column where parsing stopped and moves the cursor there. The real mistake is often just before that point — a missing comma, an extra trailing comma or an unclosed quote.

Why are single quotes or trailing commas rejected?

Standard JSON (RFC 8259) requires double quotes around keys and strings and does not allow a comma after the last item. JavaScript objects accept both, which is why copied code often fails as JSON.

What does minify do?

Minify removes all spaces and line breaks that are not inside strings, producing the smallest equivalent JSON — useful for embedding in code or reducing payload size.

Are large numbers kept exactly?

Numbers are handled as standard JavaScript numbers, so integers above 9,007,199,254,740,991 can lose precision when reformatted. Keep such IDs as strings if exactness matters.

Last updated: