To fix invalid JSON, check double quotes, commas, brackets and allowed values, then validate again after each change. Formatting adds readable spacing; validation checks whether the text follows JSON syntax. Neither step proves that the data contains the right customer, price or business rule.

Start with the MegaETools JSON Formatter & Validator and a copy of the input. Use invented sample data while learning. Before pasting real records, remove passwords, tokens and information you do not need for the task.
What is the difference between formatting and validating JSON?
A formatter makes valid data easier to read by adding indentation and line breaks. A validator checks the grammar. A readable document can still contain the wrong value, and compact JSON can be perfectly valid. After a syntax check, compare the output with what the receiving application expects.
A broken example and its corrected version
This practice input has an unquoted property name, a single-quoted string and a trailing comma. It should be rejected as JSON:
{name: 'Sample item', "quantity": 2,}
The corrected input uses double quotes for the property name and string, with no comma after the last value:
{"name":"Sample item","quantity":2}
Paste the corrected version into the formatter and run it. Check that the result still contains the same name and quantity. A useful result is not simply an error disappearing; the data should retain its intended meaning.
Common JSON errors and how to resolve them
| Situation | What to do |
|---|---|
| Property names or text use single quotes | Use double quotes around property names and string values. |
| A comma appears before } or ] | Remove the trailing comma; keep commas between neighbouring values. |
| An array or object never closes | Match each opening bracket with the correct closing bracket. |
| A note or comment appears inside the data | Keep commentary outside the JSON document. |
| A value is True, undefined or NaN | Review the intended value; JSON uses lowercase true, false and null and does not include those other tokens. |
These syntax distinctions come from RFC 8259, the JSON standard. When a parser points near the end of a document, also inspect the preceding value: a missing quote or bracket can make a later character appear to be the problem.
How do you preserve identifiers and number types?
An identifier such as “00127” may need to remain text. Writing 127 as a number loses the leading zeros. A price may need a number for calculations, while an account reference may need a string even when it contains digits. Choose deliberately rather than replacing every quoted number automatically.
For a practice comparison, “quantity”: 2 contains a number, while “quantity”: “2” contains text. Both are valid JSON. Only the receiving system can determine which is appropriate for that field. Large integers also need care when passing through systems with different numeric precision.
A reliable JSON checking workflow
- Keep the original input and work on a copy.
- Correct one syntax issue at a time and run validation again.
- Format the accepted result so nesting is easy to inspect.
- Compare field names, array lengths and representative values with the original.
- Check required fields and allowed values against the destination specification.
- Copy or download the result and validate it in the receiving workflow.
If your next step is a spreadsheet export, use our JSON and CSV guide for preserving types and IDs. Converting formats introduces a separate set of choices about headers, delimiters and missing values.
Frequently asked questions
Does valid JSON mean my API request will succeed?
No. A request can contain valid JSON but still fail because required fields, credentials or allowed values are wrong. Syntax validation is one check in the request workflow.
Can I add comments to JSON?
Standard JSON has no comment syntax. Keep explanations outside the data, or use a format explicitly supported by the system receiving it.
Does formatting fix every data problem?
No. Formatting helps you read the structure. It cannot decide whether a value is accurate or appropriate for its purpose.
Need another data task? Browse developer and data tools or try the JSON formatter with your corrected sample.
How this guide was prepared: MegaETools, a Mega Minds Tech product, prepared this guide with AI assistance using the examples and sources shown here. Examples are for practice; check your own output. Read our testing and corrections policy or report a problem.