# JSON Formatter and Validator

> A JSON formatter parses raw JSON and re-prints it with consistent indentation, or minifies it to strip every byte of whitespace. If the JSON is invalid it reports the exact line and column of the failure instead of a vague parse error.

Source: https://rankcert.com/tools/json-formatter
Free, no signup. Updated: 2026-08-29

## How to use it

1. Paste raw JSON into the editor.
2. Choose an indent, or minify to strip every byte of whitespace.
3. Invalid JSON reports the exact position of the problem so you can fix it.

## Why JSON fails to parse

Almost every parse error is one of these. JSON is far stricter than JavaScript object syntax.

| Invalid | Valid | Why |
| --- | --- | --- |
| {'a': 1} | {"a": 1} | Strings and keys must use double quotes |
| {a: 1} | {"a": 1} | Keys must be quoted |
| {"a": 1,} | {"a": 1} | No trailing commas |
| {"a": 'x'} | {"a": "x"} | No single-quoted strings |
| // comment | (remove it) | JSON has no comment syntax |
| {"a": undefined} | {"a": null} | undefined is not a JSON value |
| {"a": 01} | {"a": 1} | No leading zeros on numbers |
| {"a": .5} | {"a": 0.5} | A number needs a leading digit |
| {"a": NaN} | {"a": null} | NaN and Infinity are not valid JSON |

## Questions

### Is my JSON uploaded anywhere?

No. Parsing and formatting run in your browser with the native JSON API. Nothing is sent to a server.

### Why does my JSON fail to parse?

Almost always one of three things: a trailing comma, single quotes instead of double quotes, or an unescaped newline inside a string. JSON allows none of them.

### What indent should I use?

Two spaces is the common default for config and API payloads. Use minified output for anything you transmit - it is usually 15 to 30% smaller.

### Does formatting change my data?

No, but key order is preserved and duplicate keys collapse to the last value, which is standard JSON.parse behaviour.

### What is the difference between JSON and JSON5?

JSON5 allows comments, trailing commas, single quotes and unquoted keys. It is convenient for config files and rejected by every standard JSON parser, including this one.

### Can JSON have comments?

No. The specification has no comment syntax. Config formats that appear to allow them (tsconfig, VS Code settings) use JSONC, a superset their own parsers handle.

### Why do my large numbers change when formatted?

JavaScript parses all numbers as 64-bit floats, so integers above 2^53 lose precision. If your API returns large IDs, have it send them as strings.

### How do I format JSON from the command line?

Pipe it through jq: curl -s url | jq . formats and colourises. Node also has it built in: node -e "console.log(JSON.stringify(require('./f.json'),null,2))".

## Related tools

- [CSV to JSON](https://rankcert.com/tools/csv-to-json): Turn a CSV into an array of JSON objects in your browser, with proper handling of quoted fields, embedded commas and custom delimiters.
- [JSON to CSV](https://rankcert.com/tools/json-to-csv): Convert a JSON array into a CSV you can open in Excel or Google Sheets, with headers taken from every key that appears.
- [Password Generator](https://rankcert.com/tools/password-generator): Generate strong random passwords in your browser using the Web Crypto API, with an entropy figure so you can see how strong they actually are.
- [JWT Decoder](https://rankcert.com/tools/jwt-decoder): Paste a JSON Web Token to decode its header and payload and read every claim, including expiry. Runs entirely in your browser.
- [UUID Generator](https://rankcert.com/tools/uuid-generator): Generate cryptographically random UUID v4s, or time-ordered UUID v7s that index far better as database primary keys.
- [Regex Tester](https://rankcert.com/tools/regex-tester): Test a JavaScript regular expression against sample text, see every match with its position and capture groups, and get real errors for invalid patterns.