Practical guide
How to Format and Validate JSON (With Examples)
JSON is a text format for structured data used by APIs, configuration files, and web applications. A JSON value can be an object, an array, a string, a number, true, false, or null. Formatting makes that text easier to read, minifying makes it compact, and validating checks whether the text follows JSON rules at all. This guide explains all three, using the SmartEdgeTools JSON Formatter and Validator as the example tool.
By Ather Saud · Updated on November 1, 2026
What valid JSON looks like
An object uses curly brackets, with double-quoted keys, a colon, and values separated by commas, for example {"name":"Mina","items":[1,2]}. An array uses square brackets. Strings must use double quotes, not single quotes. Numbers do not use quotes. True, false, and null are written in lower case.
Whitespace between tokens does not change the data. That is why the same JSON can be written on one long line or spread over many lines. Formatting only changes whitespace and indentation; it does not rename fields, reorder data in a meaningful way, or change values.
Format, minify, and choose indentation
Paste a JSON value into the tool, choose an indent of 2 spaces, 4 spaces, or a tab, then select Format & validate. The tool parses the input and prints the same data with consistent indentation, so nested objects and arrays are easier to follow. Select Minify instead to remove insignificant whitespace for a compact copy.
The tool also offers a Load example button, which fills in {"name":"SmartEdgeTools","features":["format","validate"],"active":true}. Try formatting that first, then minifying the result, to see that both operations keep the same fields and values. Copy the output only after it validates.
How to read a validation error
If the input is invalid, the tool shows an error message and, when the parser reports a position, a line and column hint. Use that hint as a starting point, not as a perfect pointer: the actual mistake is often just before the reported position, such as a missing comma or bracket on the previous line.
Check the structure around that point. Count opening and closing brackets, check that every object key is quoted, and check that commas separate items but do not follow the last item. Fix one error at a time and run the tool again, because a single early error can hide later ones.
Common errors and how to fix them
Single quotes are the most common cause: {'name':'Mina'} is not JSON, even though it looks similar in other languages. Change single quotes to double quotes. Unquoted keys, such as {name:"Mina"}, are also invalid; quote the key. A trailing comma, such as {"a":1,}, is invalid; remove the comma after the last item.
A missing comma, a missing closing bracket, or a value such as undefined, NaN, or a date written without quotes will also fail. JSON has no comments, so a line starting with // inside JSON is invalid. If you need a note, keep it outside the JSON value.
What the formatter does not do
The formatter does not repair broken JSON and does not guess at a correction. That is deliberate: guessing could change a value without you noticing. It also does not check whether the data is correct for your application, only whether the text is valid JSON. A valid JSON value can still contain the wrong field name, the wrong number, or a missing item for your task.
Processing happens in your browser, and the formatter code does not send the text you enter to a server. That is useful for ordinary API responses and configuration, but still avoid pasting secrets, passwords, or highly sensitive personal data into any website, especially on a shared device.
A practical workflow
Copy the JSON from your API response, file, or error message, paste the complete value, and format it. Read the nested structure, check the fields you need, and copy the formatted or minified version as required. If the tool reports an error, fix the syntax, validate again, and only then use the result in your application or configuration.
For a large file, work on a copy and keep the original unchanged until the formatted version validates. If a value is very large, check that you pasted the complete value, because a cut-off ending will look like a missing bracket error.
| Invalid example | Problem | Fix |
|---|---|---|
| {'name':'Mina'} | Single quotes | Use double quotes: {"name":"Mina"} |
| {name:"Mina"} | Unquoted key | Quote the key: {"name":"Mina"} |
| {"a":1,} | Trailing comma | Remove the last comma: {"a":1} |
| {"items":[1,2]} // note | Comment in JSON | Remove the comment or keep it outside the JSON |
Key takeaways
- JSON requires double-quoted strings and keys, and no trailing commas.
- Formatting changes whitespace only; minifying removes it. Neither changes values.
- Use the error line and column as a starting point, fix one error at a time, and validate again.
Frequently asked questions
What is the difference between formatting and minifying JSON?
Formatting adds consistent indentation to make JSON readable. Minifying removes insignificant whitespace to make it compact. Both keep the same data.
Why is my JSON invalid if it looks correct?
Common causes are single quotes, unquoted keys, a trailing comma, a missing comma or bracket, and comments. Check the reported line and column, then check just before that position.
Can the formatter fix my JSON automatically?
No. It reports the error but does not guess a correction, so that values are not changed unexpectedly.
Is my JSON uploaded when I use the tool?
The formatter runs in the browser and its code does not send the entered JSON to a server. Avoid sensitive data on a shared device.