If you do not know whether the string is JSON, validate it. If it is valid and you cannot see the structure, format it. If it is valid and you need a smaller body or a one-line log field, minify it. Do not minify to “fix” a parse error. Do not format as a substitute for a yes-or-no check when the error is unclear.
On YallaSolve those three jobs are separate pages on purpose. The JSON Validator does not indent. The JSON Formatter indents or minifies after a successful parse. The JSON Minifier only compact-prints. This guide is how to format, validate and minify JSON as one procedure that uses more than one page.
Start here when you see JSON.parse throw, when a client rejects the body, or when you edited the file by hand. Paste the payload into the validator. Empty input is not valid JSON. A trailing comma, a single-quoted string, a comment, or an unquoted key will fail.
Read the first unexpected token. That character is the start of the search. Fix it, validate again, and only then decide whether you need indentation or a compact string. Repeating format or minify on the same broken text will not invent a missing quote.
Once validate reports a valid object or array, paste the same string into the JSON Formatter and choose Format. Indentation makes missing braces and mismatched arrays visible to a human. This is the right step before you chase a logic bug in an API client.
Format does not change keys or values. If you need to compare two payloads by eye, format both. If you need a structural list of value changes, follow how to compare two JSON documents. If you need field paths rather than indentation, follow how to work with nested JSON.
Minify when the payload is valid and you need less text: a request body you will send many times, a log line that must stay on one record, or a file you will store compact. Use the formatter’s Minify action or the dedicated minifier page when that page is published. A smaller invalid string is still invalid.
HTTP compression can also shrink whitespace on the wire. Minify still helps processes that store the raw body. It is not gzip and it is not encryption.
Suppose a service returns:
{"user":{"id":12,"name":"Ada"},"roles":["admin","developer"]}
Validate: valid JSON object. Format: you can see user and roles. You notice you meant to add a third role. You edit in a proper editor, validate again, then minify before you paste the body into a client:
{"user":{"id":12,"name":"Ada"},"roles":["admin","developer","support"]}
If instead the service had returned {"user":{"id":12,}}, validate fails on the trailing comma. You do not format or minify until that comma is gone.
Typical first tokens: a comma after the last property, a ' instead of ", a // comment, or a } that closed too early. The validator’s line and column, when present, are a hint from the browser position. Fix that site, validate, and only then format.
JavaScript object literals are not JSON. If you are converting a literal from application code, quote the keys, drop comments and trailing commas, and switch to double quotes. Then run the same three steps: validate, format if you need to read, minify if you need it small.
The same procedure applies when the payload comes from Magento, WordPress, or a log shipper. Those systems often wrap or prefix output. If validate fails at position 0, strip notices and BOMs before you argue about commas. If validate succeeds and you still cannot find a field, format. If a worker will store the body, minify last.
Do not build a habit of “hit every button.” Format and minify both require a successful parse. Running them on a broken string wastes time and, on some other websites, silently changes nothing while you assume the tool did work. On YallaSolve the status tells you. Read it.
When you hand the result to someone else, say which form you sent: formatted fixture, minified body, or raw invalid dump. Those are different artifacts. This guide exists so a team can share one order of operations instead of three contradictory wiki pages.
Validate if the string might be illegal. Format if it is valid and unreadable. Minify only after it is valid and you need a smaller string.
No. Minify will not rewrite invalid JSON. Remove the comma, validate, then minify.
They answer different questions. One URL that “does everything” makes the search result and the page harder to trust.
No. Validate, format, and minify on YallaSolve run in the browser.
Quote the keys, switch to double quotes, drop comments and trailing commas, then validate. See the guide on converting a JavaScript object literal to JSON.