JSON Formatter & Validator Online
Paste JSON to validate it and instantly get a beautifully formatted (or minified) version. Invalid JSON shows a clear error message.
By DevCalcHub Editorial Team · Last updated:
How it works
The tool parses your input using standard JSON parsing. If it's valid, it's re-serialized with your chosen indentation (or none, for minify). If it's invalid, you get the exact parsing error.
Example
Beautifying a compact JSON object:
How to use the JSON formatter
- Paste or type your JSON into the input box — an API response, a config file, a log line or anything else.
- Choose an output format: beautify with 2-space or 4-space indentation, or minify to remove all whitespace.
- If the JSON is valid, copy the formatted output. If it isn't, read the error message to find where parsing failed.
JSON syntax rules
JSON (JavaScript Object Notation) is stricter than JavaScript object syntax. Valid JSON must follow these rules:
- Keys must be strings in double quotes: {"name": "Asha"}, not {name: "Asha"}.
- Strings must use double quotes — single quotes are not allowed.
- Values can only be strings, numbers, true, false, null, objects or arrays. undefined, functions, dates and NaN are not valid JSON.
- No trailing commas after the last item in an object or array.
- No comments — neither // nor /* */.
- Special characters inside strings, such as quotes, backslashes and newlines, must be escaped: \", \\, \n.
Common JSON errors and how to fix them
| Invalid | Problem | Fix |
|---|---|---|
| {"a": 1,} | Trailing comma | {"a": 1} |
| {'a': 1} | Single quotes | {"a": 1} |
| {a: 1} | Unquoted key | {"a": 1} |
| {"a": 1 "b": 2} | Missing comma | {"a": 1, "b": 2} |
| {"a": undefined} | Unsupported value | {"a": null} |
| [1, 2 | Missing closing bracket | [1, 2] |
Beautify or minify?
Beautified JSON adds line breaks and indentation, so nested data is easy to read, review and compare in version control. Use it when debugging API responses or editing configuration files.
Minified JSON removes every unnecessary space and line break, producing the smallest possible output. Use it when sending JSON over a network, storing it, or embedding it in another file. Both formats contain exactly the same data.
Things to watch out for
- Large numbers: numbers above 9,007,199,254,740,991 (2^53 − 1), such as some 64-bit database IDs, lose precision when parsed in JavaScript. Send them as strings if exact values matter.
- Duplicate keys: if an object contains the same key twice, only the last value is kept when the JSON is formatted.
- Key order: keys keep their original order, except keys that look like whole numbers (such as "1" or "42"), which JavaScript places first in ascending order.
- Encoded payloads: if a field contains Base64 data, decode it with the Base64 Decoder; for epoch dates, use the Unix Timestamp Converter.
Frequently asked questions
What makes JSON invalid?
Common issues include trailing commas, single quotes instead of double quotes, unquoted keys, or missing brackets/braces. The error message shown points to roughly where the parser got stuck.
Does this tool send my data anywhere?
No. All formatting and validation happens directly in your browser — your JSON is never sent to a server.
What is the difference between JSON and a JavaScript object?
JSON is a text format based on JavaScript object syntax, but stricter: keys and strings must use double quotes, and it cannot contain functions, undefined, comments or trailing commas. A JavaScript object is a live value in memory; JSON is how that data is written down and exchanged.
Does this tool support comments or JSON5?
No. The formatter follows the standard JSON specification, so comments, single quotes, unquoted keys and trailing commas are reported as errors. Remove them to get valid JSON.
Does formatting change my data?
No. Beautifying and minifying only change whitespace. The one exception is very large numbers beyond JavaScript's safe integer limit, which can lose precision when parsed.
Can I format large JSON files?
Yes. Because formatting happens in your browser, the limit depends on your device's memory. Files of several megabytes format comfortably on most computers.
How do I validate JSON?
Paste it into the input box. If it is valid, you will see the formatted output; if not, you will see the parser's error message, which usually indicates the position where the problem was found.
Related tools
Input
Formatted JSON
{
"name": "example",
"active": true,
"values": [
1,
2,
3
]
}