Start with validation, not guesswork
When a payload fails, the first goal is not to make it pretty. It is to confirm that the JSON is actually invalid and then narrow down the syntax issue. Use JSON Validator or Fix Invalid JSON to check the payload before editing.
Step 1: Look for the common mistakes first
Most invalid JSON errors are caused by a small group of problems:
- Trailing commas after the last item in an array or object.
- Single quotes instead of double quotes.
- Missing closing braces or brackets.
- Unquoted keys copied from JavaScript object syntax.
- Comments pasted into a JSON block.
Step 2: Repair the payload in small passes
Do not rewrite the entire object at once. Fix one syntax issue, validate again, and repeat. That approach is faster than making several guesses and losing track of what changed.
Example: trailing comma
{
"user": "Ada",
"roles": ["admin", "editor",]
}
Remove the final comma after "editor" so the array closes cleanly.
Example: single quotes
{ 'name': 'Ada' }
JSON requires double quotes:
{ "name": "Ada" }
Step 3: Format the repaired JSON
Once the payload validates successfully, run it through JSON Formatter. Pretty printing makes it easier to confirm nesting, compare changes, and reuse the result in code or docs.
Step 4: Check your workflow context
If the JSON came from a request body, log file, or copied example, ask why it became invalid in the first place. Did someone paste JavaScript object syntax into a JSON field? Did a log line cut off the final brace? That context can prevent the same bug from coming back.