Practical guide
How to Fix Invalid JSON
A JSON formatter can make valid data easier to read, but it cannot repair an arbitrary broken input without guessing what you intended. Start with the parser error, then check syntax one small piece at a time. ToolVerse parses JSON locally, so you can test an example without uploading it.
How to do it
- 1. Paste the smallest failing example
Remove unrelated fields until the error remains. Redact tokens, passwords, and personal data before sharing an example with someone else.
- 2. Read the first parser error
Fix the earliest problem reported. A missing quote or brace near the beginning can cause several later-looking errors.
- 3. Format only after it parses
Once the JSON is valid, use two-space formatting to inspect nesting and values. Test the result in the application that will consume it.
Use double quotes for names and strings
JSON object keys and string values require double quotes. {"name":"Ada"} is valid; {name:"Ada"} and {"name":'Ada'} are not valid JSON. JavaScript object literals may allow forms that JSON does not.
Numbers, true, false, and null are not quoted unless the receiving API specifically expects strings. A syntactically valid value can still be the wrong type for that API.
Remove trailing commas and comments
A comma separates items in an object or array, but cannot appear after the last item in standard JSON. For example, [1,2] is valid and [1,2,] is not. Standard JSON also has no // or /* */ comments.
When a parser reports an unexpected token near a closing bracket, inspect the item immediately before it. The error location is a clue, not always the exact character you need to change.
Check matching brackets and nesting
Objects use braces and arrays use square brackets. Each opening delimiter needs the corresponding closing delimiter. If you are working with a long response, format a smaller valid section first, then add the removed fields back gradually.
The ToolVerse formatter checks syntax with the browser JSON parser and clears stale output on invalid input. It does not check a JSON Schema, required API fields, or business rules. A separate validator is needed for those checks.
Keep debugging data private
Local parsing means the input is not uploaded by the formatter. Your clipboard, browser extensions, and any app you paste the output into are separate privacy boundaries. Avoid placing live secrets in examples or bug reports.
Frequently asked questions
Why will the formatter not format my input?
It only formats syntactically valid JSON. Correct the first parser error, then try again.
Can valid JSON still fail in an API?
Yes. An API may expect a particular schema, type, or authorization even when the JSON syntax is valid.
Are comments allowed in JSON?
No. Standard JSON does not support JavaScript-style comments.