How to use the json formatter
- 1Paste your JSON into the left box.
- 2Pick 2 spaces, 4 spaces, tabs, or Minify.
- 3If the JSON is invalid, read the error with its line and column, then fix it.
- 4Optionally sort keys A–Z to make objects easier to compare.
- 5Copy or download the result.
Formatting and validation
The formatter parses your JSON with the browser's own strict parser, then writes it back out with the indentation you choose. If parsing fails, the error and its line and column are shown, so you can jump straight to the problem.
Common JSON errors
- Trailing commas:
{"a": 1,}is not allowed. - Single quotes: strings and keys must use double quotes.
- Unquoted keys:
{name: "Ada"}must be{"name": "Ada"}. - Comments: standard JSON does not allow // or /* */ comments.
- Special values:
undefined,NaNand functions are not valid JSON.
Minify or beautify?
Beautified JSON is easier for people to read and review. Minified JSON removes all optional whitespace, which makes files and API payloads smaller.
Sorting keys
Sorting object keys alphabetically does not change what the data means, but it makes two versions of a file much easier to compare. Arrays keep their original order.
Privacy
Your JSON is processed only in your browser, so it is safe to format API responses and config files that contain private data.
Frequently asked questions
Is my JSON sent to a server?
No. Parsing and formatting happen entirely in your browser.
Why does valid JavaScript fail as JSON?
JSON is stricter than JavaScript: keys need double quotes, and comments, trailing commas and single-quoted strings are not allowed.
Does sorting keys change my data?
No. Object key order has no meaning in JSON. Array order is kept exactly as it was.
How large a file can I format?
Files of several megabytes work on most computers. Very large files depend on your device's memory.
Last updated