How to format and validate JSON
- Paste your JSON into the Input box.
- Click Format to pretty-print it with two-space indentation, or Minify to remove all whitespace.
- Click Validate to check the syntax without changing anything. If the JSON is invalid, the parser error tells you what went wrong and where.
- Copy the result with the copy button.
Common JSON errors and how to fix them
- Trailing commas: a comma after the last item of an object or array is not allowed.
- Single quotes: strings and keys must use double quotes.
- Unquoted keys: every key must be a double-quoted string.
- Comments: standard JSON does not support // or /* */ comments.
- Invalid values: undefined, NaN, Infinity and functions are not valid JSON. Use null or a string instead.
- Unescaped characters: line breaks and tabs inside a string must be written as \n and \t, and double quotes as \".
// Invalid
{ name: 'Ada', "tags": ["dev", "math",], }
// Valid
{ "name": "Ada", "tags": ["dev", "math"] }Format vs minify
Formatted JSON is for people: indentation and line breaks make nested objects easy to read, review and compare.
Minified JSON is for machines: removing whitespace makes payloads smaller, which matters for API responses, configuration stored in environment variables and data embedded in pages.
Both produce the same data. Switching between them never changes keys or values.
Frequently asked questions
- Is my JSON sent to a server?
- No. Formatting, minifying and validation all run in your browser with the built-in JSON parser. Your data is never uploaded or stored, so it is safe to paste API responses and configuration.
- Does it support JSON5 or JSON with comments?
- No. The tool follows standard JSON (RFC 8259), the format that APIs and JSON.parse expect. Remove comments and trailing commas to make JSON5 or JSONC valid JSON.
- Why did the order of some keys change after formatting?
- Keys keep their original order, except keys that look like non-negative integers, such as "1" or "42". JavaScript always lists those first in ascending order, so they move to the top of their object.
- What happens with duplicate keys?
- JSON allows duplicate keys syntactically, but only the last value is kept when the JSON is parsed. Formatting therefore shows each key once, with its last value.
- Is there a size limit?
- There is no fixed limit. Large files are processed by your device, so multi-megabyte documents may take a moment to format.
- What is the difference between validating and formatting?
- Validate only checks that the input is well-formed JSON. Format checks it too and then rewrites it with indentation. Neither checks your data against a schema.