When a JSON formatter reports an error, fix the first syntax problem before changing the rest of the document. Start with quotes, commas and matching brackets, then validate again. An error location usually identifies where parsing became impossible; the missing punctuation may be immediately before that position.
Use the JSON Formatter and Validator to inspect a working copy. It offers indentation, minification and optional key sorting. Keep the original unchanged until you have checked that the corrected document still contains the intended values.
First check that your input is JSON
An API response may contain an HTML error page instead of the data you expected. A copied example may be a JavaScript object, a Markdown code block or several separate JSON records. None of those should be repaired by blindly adding quotation marks.
Look at the beginning of the response. If it starts with an HTML tag such as <!DOCTYPE html>, inspect the request URL, HTTP status and response body. If it includes Markdown fences, copy only the JSON inside them. Confirm the producing system’s expected format before modifying the payload.
Five small errors you can isolate
The examples below are deliberately short so you can see the exact change. They are original demonstration inputs, not production records. MDN documents common syntax failures in its JSON parsing error reference.
1. An unquoted property name
This JavaScript-style object is not valid JSON:
{product: "Travel mug", "stock": 12}
Put the property name in double quotes:
{"product": "Travel mug", "stock": 12}
Do not replace every quote in a long document at once. An apostrophe inside a valid string may be ordinary text.
2. A trailing comma
The comma after the last array item causes this input to fail:
{"sizes": [250, 350, 500,]}
Remove that final comma:
{"sizes": [250, 350, 500]}
Keep the commas that separate actual items. Removing all commas would introduce a different error.
3. Quotes inside a string
Unescaped quotation marks end the string too early:
{"label": "Choose "large" for this item"}
Escape the quotation marks that belong to the text:
{"label": "Choose \"large\" for this item"}
After parsing, the value contains the word large in quotation marks. The backslashes make that representation possible inside the JSON text.
4. A missing comma between properties
Here the next property begins before a separator appears:
{"color": "navy" "available": true}
Add the comma after the first value:
{"color": "navy", "available": true}
If an error highlights available, check the end of the preceding value as well as the highlighted word.
5. A missing closing bracket
The array closes, but the containing object does not:
{"order": {"items": ["mug", "lid"]}
Close both objects:
{"order": {"items": ["mug", "lid"]}}
Work from the innermost container outward. Indentation makes the structure easier to inspect once the document parses.
A reliable repair sequence
- Save the original input. Use a separate copy for diagnosis.
- Paste one complete JSON value. Do not include a response heading, code fence or a second independent object.
- Press Format JSON. Read the reported message. Browser wording varies, and a line or column is not always available.
- Make one targeted correction. Start near the earliest error location and inspect the character before it.
- Validate again. The next error may only become visible after the first is fixed.
- Review the successful output. Compare important values with the original before copying it back into an application.
The Text Compare Tool can help you review an original and corrected copy. Treat differences in whitespace separately from changes to names, numbers and string contents.
Valid syntax does not prove the data is correct
A document containing {"quantity": "many"} can parse successfully even when an application expects an integer. Likewise, an empty object can be valid JSON while missing every field your integration requires. After syntax validation, check the receiving API’s field names, types and required values.
The current formatter uses JavaScript parsing and serialization. MDN’s JSON.parse documentation notes that numeric values can lose precision during conversion. Take particular care with large numeric identifiers: follow the source system’s specification and use strings when that specification requires them. Do not assume a successful formatting step preserved every digit.
Leave optional key sorting off during the first diagnosis, so you can compare the original sequence more easily. Also resolve duplicate property names at the source; a parsed object may retain only one value. A formatter should not be used as proof that a payload has no such ambiguities.
What to do when the same error keeps returning
If manual corrections disappear on the next export, fix the producer rather than each downloaded file. Record a small failing sample, the expected structure and the exact parsing message. That gives the developer or integration owner a reproducible case instead of a vague “invalid JSON” report.
Writing documentation for the corrected integration? Our title-writing checklist can help you label the guide with the specific problem it solves.