JSON Debugging
JSON Trailing Comma Debugging Guide
Find and remove JSON trailing commas while distinguishing strict JSON from JavaScript objects, JSON5 and editor-specific configuration formats. This reference is written for developers who need practical validation behavior, reviewable rules and safe examples rather than copied snippets with no explanation.
Recommended workflow
| Step | Why it matters |
|---|---|
| Confirm the format | Verify the consumer expects strict JSON rather than JavaScript, JSON5 or another configuration grammar. |
| Use parser location | Inspect the token immediately before a closing brace or bracket at the reported offset. |
| Check nested collections | Trailing commas can occur in objects and arrays several levels below the visible failure. |
| Fix the producer | Configure serializers and templates to emit separators between items, never after the final item. |
Starter snippet
invalid: {"enabled": true,} valid: {"enabled": true}Review checks
- Validate with the same parser used in production.
- Test empty and single-item collections.
- Keep comments out of strict JSON.
- Add generated payloads to automated tests.
Common mistakes
- Removing every comma near the error.
- Renaming a .json file to hide invalid syntax.
- Assuming browser JavaScript parsing proves JSON validity.
Validation should help users correct input while protecting systems from bad data. Keep syntax checks, product policy, security review and deliverability checks separate.
Related Formalint references
Continue with JSON Lint Error, Json Formatting Guide, Config File Validation.