You open an API response or a config file and get one long line of braces, quotes and commas with no structure you can follow. Or the opposite problem: a service rejects your payload as invalid and gives you no hint about where the problem sits. Both jobs, making JSON readable and finding out whether it is legal at all, are mechanical, and they should take seconds.

The free JSON Formatter and Validator on Ovatly does both in your browser. It pretty-prints JSON with your choice of two or four space indentation, minifies it back to one line, and validates it with an error message in plain words when it will not parse. This guide explains when to format, when to only validate, when to minify, and how to read the error when the answer is no.

Contents

  • Quick answer
  • Three buttons, three different jobs
  • The strict standard: what counts as invalid
  • Two spaces or four spaces?
  • How to format and validate JSON, step by step
  • Worked example: formatting a compact object
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

To format JSON online, paste it into the JSON Formatter and Validator, choose two or four space indentation, and press Format. To check JSON without changing a character of it, press Validate only instead. To make it compact again, press Minify. If the JSON will not parse, the tool shows a plain-words error under the result naming the problem. Validation follows the strict JSON standard, so trailing commas, single-quoted strings, unquoted keys and comments are all reported as errors. Nothing is uploaded: parsing and formatting run on your device.

Three buttons, three different jobs

Format, Validate and Minify sound like variations of one action, but each answers a different question.

Format answers "can I read this?" It rewrites the JSON with consistent indentation, one value per line, so nesting becomes visible and a missing bracket is easier to spot. Developers use it to read API responses, check config files and clean up payloads before sending them.

Validate only answers "is this legal JSON?" It checks the text and leaves it completely untouched. That is the safer choice when the file is not yours to rewrite, when a diff would be polluted by reindentation, or when you only need a yes or no before handing the payload to something else.

Minify answers "can this be smaller?" It strips the indentation and newlines back out, returning the JSON to one compact line. The data is the same; only the layout changes. Minified JSON is what you embed or send when nobody needs to read it by eye.

The strict standard: what counts as invalid

The validator follows the strict JSON standard, and it does not grade on a curve. Trailing commas, single-quoted strings and unquoted keys are all invalid JSON and will be reported. So are comments: JSON has no comment syntax, so a file with comments in it is not JSON, however reasonable it looks in an editor that tolerates them. Files written for JSONC-aware tools need the comments removed before they will validate here.

This strictness is the point. A lenient checker that accepts almost-JSON tells you nothing about whether a strict parser downstream, which is most of them, will accept the same file. When the tool says invalid, the error message under the result names the problem the parser found, such as an unexpected character or a missing comma, so you fix the actual fault instead of hunting through the whole document.

Two spaces or four spaces?

The indent choice is cosmetic and changes nothing about the data. Two spaces keeps deeply nested documents narrower, which matters when a payload has many levels and lines would otherwise run off the screen. Four spaces makes each level easier to distinguish at a glance in shallow documents. Pick the one you can read, and stay consistent inside a project so diffs stay clean. If you only need a verdict and not a rewrite, skip the choice entirely and use Validate only.

How to format and validate JSON, step by step

  1. Open the JSON Formatter and Validator and paste your JSON into the input box.
  2. Choose an indent size if you plan to format.
  3. Press Format to pretty-print, Minify to compress, or Validate only to check without changing anything.
  4. Copy the result from the result panel, or read the plain-language error and fix the input.

Worked example: formatting a compact object

Take this compact input, the kind an API returns:

{"name":"Ovatly","tools":250,"free":true}

Pressing Format with two-space indentation produces:

{
  "name": "Ovatly",
  "tools": 250,
  "free": true
}

Nothing about the data changed: the same three keys, the same values, the same types. What changed is that the structure is now visible at a glance, which is the entire value of formatting. Running Minify on the formatted version returns the original one-line form.

Limitations and honest tradeoffs

Very large pastes may take a moment, because parsing happens on your device rather than on a server built for it. Tens of megabytes of JSON will still work, but not instantly.

Number precision follows JavaScript: integers beyond 2^53 can lose exactness when reformatted. That only bites with very large identifiers stored as bare numbers, but if your payload carries them, validate only instead of formatting, or store the identifiers as strings.

And the strictness cuts both ways. The tool will not rescue almost-JSON: it will not strip comments, forgive a trailing comma, or guess what you meant. It reports the error in plain words and leaves the fixing to you, which keeps the verdict trustworthy.

Common mistakes

  • Assuming a trailing comma is harmless. JavaScript object literals allow one; JSON does not. It is the single most common reason hand-written JSON fails validation.
  • Writing strings with single quotes. JSON requires double quotes around keys and string values.
  • Leaving comments in a config file. Many config formats look like JSON but allow comments. Strict JSON does not, and the validator will say so.
  • Formatting when you only needed a verdict. Format rewrites the text. If the file must stay byte for byte identical, use Validate only.
  • Ignoring the error message. The plain-words error names the problem the parser found. Read it before re-checking the whole document by eye.

FAQs

Why does the tool say my JSON is invalid? The error message under the result names the problem the parser found, such as an unexpected character or a missing comma. Common causes are trailing commas, single quotes, and comments, none of which JSON allows.

What is the difference between Format and Validate? Format rewrites the JSON with consistent indentation. Validate only checks it and leaves your text untouched, which is safer when you just need a yes or no.

Can it format JSON with comments (JSONC)? No. Comments are not part of the JSON standard, so they are reported as errors. Remove comments first, or use a JSONC-aware editor for those files.

Is my JSON sent to a server to be checked? No. Parsing and formatting run in your browser with JavaScript's built-in JSON parser. API keys or private payloads you paste never leave your device.

Can formatting change my numbers? Number precision follows JavaScript, so integers beyond 2^53 can lose exactness when reformatted. Ordinary values, including decimals and small integers, come through unchanged.

Conclusion

Formatting, validating and minifying are three small jobs that share one tool: the JSON Formatter and Validator makes JSON readable, gives a strict yes or no without touching your text, and compacts it again when you are done. Once your JSON is valid and readable, our guide to converting JSON to CSV for Excel or Google Sheets shows how to turn an array of records into a spreadsheet. For more guides in this series, see our Data and JSON Tools guides.

References