JSON Formatter & Validator

Beautify, minify and validate JSON instantly. Everything runs in your browser — your data never leaves your device.

How to format JSON

  1. Paste your JSON into the top box. It can be an object, an array or even a single value such as a string or number.
  2. Choose an indent of 2 spaces, 4 spaces or a tab, then click Format. Click Minify instead to compress it to a single line.
  3. If the JSON is invalid, the browser's own parse error appears in red and the output stays empty. Fix the problem and run it again.
  4. When you see the green “Valid JSON” message, click Copy result.

Format vs minify, with an example

Formatting adds line breaks and indentation so you can read nested data. Minifying removes every optional space and newline. Take this input:

{"id":7,"tags":["a","b"],"owner":{"name":"Ana","active":true}}

Formatted with 2 spaces it becomes eight short lines, one property per line, with the tags array and owner object indented one level deeper. Minified, it returns to a single line with no spaces at all. The two outputs are equivalent to any JSON parser. Minifying often shrinks pretty-printed API responses noticeably, which is why production endpoints send compact JSON while developers read formatted JSON.

What the validator catches

JSON is stricter than JavaScript object syntax. The formatter rejects the mistakes below, because they are not legal JSON:

  • Trailing commas such as {"a":1,} or [1,2,].
  • Single quotes around keys or strings. JSON requires double quotes.
  • Unquoted keys like {name:"Ana"}.
  • Comments (// or /* */). Config files such as tsconfig allow them, but standard JSON does not.
  • Values like undefined, NaN or Infinity, and numbers with leading zeros such as 007.
  • Unescaped control characters, for instance a raw line break inside a string. Use \n instead.

The error text comes from your browser's JSON parser, so its wording differs between Chrome, Firefox and Safari. It usually names the unexpected token and often a position or line, which is the quickest way to find the bad character in a large file.

Limits and edge cases of this tool

Formatting works by parsing the text and writing it back out, which has consequences worth knowing:

  • Large integers lose precision. JavaScript stores numbers as 64-bit floats, so an ID such as 12345678901234567890 comes back as 12345678901234567000. Database IDs above 9,007,199,254,740,991 should be sent as strings.
  • Number spelling is normalized. 1.0 becomes 1 and 1E2 becomes 100. The value is the same, the text is not.
  • Integer-like keys are reordered. In JavaScript objects, keys such as "10" and "2" are listed in numeric order before other keys, so a map keyed by numbers may come out in a different order.
  • Duplicate keys collapse. If the same key appears twice, only the last value survives.
  • Escapes are simplified. A sequence like \u00e9 is written back as the plain character é.
  • Surrounding whitespace is trimmed, and an empty input produces nothing.

Apart from those normalizations the tool does not sort keys, remove fields or alter values, so formatted output remains safe to diff against the original structure.

Tips for common situations

Debugging an API response: paste it, format with 2 spaces, and scan for the one path you care about. Committing config files: use the indent your repository already uses, usually 2 spaces, so the diff shows only real changes. Pasting into a URL, a log line or a single-line environment variable: minify first. Copying from a log that wraps the JSON in quotes with backslashes: the escaped text must be unescaped first, otherwise the parser will see a string, not an object.

Is it private and safe?

Yes. Parsing and formatting both run in your browser with the built-in JSON.parse and JSON.stringify. Your data is never uploaded, so pasting tokens, configs or customer records does not expose them to a server.

Related guides: How to format and validate JSON, How to fix JSON syntax errors, How to minify JSON and JSON escape characters explained.

Frequently asked questions

Why does it say my JSON is invalid?

The usual causes are a trailing comma, single quotes instead of double quotes, unquoted keys, comments or a missing bracket. The error message names the unexpected character and often its position, so search for that spot in your text.

Does it sort or change my data?

It does not sort keys or edit values, but it re-serializes the data. That means numbers like 1.0 become 1, duplicate keys keep only the last value, and keys that look like whole numbers are listed first in numeric order.

Why did a long ID number change after formatting?

JavaScript numbers are 64-bit floats and can only represent integers exactly up to 9,007,199,254,740,991. Larger values get rounded when parsed. If the ID matters, store and send it as a string in the source data.

Can it format JSON with comments?

No. Standard JSON does not allow comments, and the parser used here is strict. Remove the comment lines first, or use a tool that supports JSON5 or JSONC if the file comes from a config that allows them.

What is the difference between 2 spaces, 4 spaces and tabs?

Only appearance and file size. All three produce equivalent JSON. Two spaces is the most common convention for web projects, four spaces matches many Python and Java style guides, and tabs let each reader choose their own display width.

Is there a size limit?

There is no fixed limit in the tool, but it works in your browser's memory. Files of a few megabytes format instantly. Very large files of tens of megabytes may make the page slow, depending on your device.

Is my JSON uploaded?

No. Everything runs on your device with your browser's built-in JSON functions, and nothing is sent anywhere. It is safe for configs and payloads that contain private data.

Is it free?

Yes. It is completely free with no sign-up and no usage limit.