Why JSON Formatter Shows Invalid JSON
Troubleshoot invalid JSON errors caused by trailing commas, missing quotes, broken brackets, comments, and pasted API payload issues.
Use The Tool
This guide supports the JSON Formatter tool. Use the tool for the actual conversion or formatting step, then use this page to understand the method, edge cases, and next actions.
Fast Answer
A JSON formatter shows an invalid JSON error when the input cannot be parsed as valid JSON. The most common causes are trailing commas, unquoted object keys, single quotes around strings, missing closing braces, comments copied from JavaScript, or invisible characters from pasted logs.
Formatting does not repair broken structure automatically. First validate the payload, fix the syntax, then format it for readability.
Common Causes
- Trailing comma after the last object or array item.
- Object keys without double quotes.
- Single quotes used for strings instead of double quotes.
- Missing closing bracket or brace in a copied response.
- Comments copied from JavaScript into a JSON-only parser.
- Smart quotes or hidden characters pasted from documents.
Error Pattern Reference
| Pattern | What It Usually Means | Fix |
|---|---|---|
| Unexpected token } | A trailing comma or missing value appears before a closing brace. | Remove the comma or add the missing value. |
| Unexpected token at position 0 | Input may be empty, HTML, or a server error page instead of JSON. | Confirm the copied response starts with { or [. |
| Unexpected string | A comma may be missing between properties. | Add the separator between key-value pairs. |
| Unexpected token / | A JavaScript-style comment was pasted into JSON. | Remove comments before parsing. |
Safe Workflow
- Paste a small sample first if the payload is large.
- Use the JSON Validator when you need the exact syntax error before formatting.
- Keep the original payload until the formatted output is accepted by the destination system.
- Do not assume formatting changes values; it should only change whitespace when input is valid.
Related Tools
Explore The Full Category
Need another related task? Open Developer Tools for the full tool set, quick-reference examples, and related category paths.