JSON is stricter than JavaScript object literals. Trailing commas, comments and single-quoted strings can break API requests and config files.
Symptoms
- JSON.parse fails with an unexpected token error.
- API returns invalid JSON or bad request.
- A config works in JavaScript but fails in a JSON parser.
Likely causes
- Trailing comma after the last array or object item.
- Comments inside JSON.
- Single quotes or unquoted property names.
Fix steps
- Paste the payload into a JSON validator.
- Remove trailing commas and comments.
- Pretty format the valid result before sending it to an API.
Verify the fix
- Validate JSON syntax.
- Minify the output and compare it with the original payload.
- Run the API request with a known-good cURL command.
FAQ
Are trailing commas allowed in JSON?
No. Some JavaScript contexts allow them, but JSON does not.
Can comments be used in JSON?
No. Use a different config format if comments are required.
Related tools and guides
Last updated: May 18, 2026