DEV Community

Inamullah Khan
Inamullah Khan

Posted on

How to Fix Invalid JSON Errors Online

How to Fix Invalid JSON Errors Online

Invalid JSON usually comes from small syntax mistakes.

The most common ones are:

  • trailing commas
  • single quotes instead of double quotes
  • missing quotes around object keys
  • unclosed brackets
  • comments inside JSON
  • extra commas

Example of invalid JSON

{
  "name": "ToolsFam",
  "type": "Browser tools",
}
Enter fullscreen mode Exit fullscreen mode

The problem is the trailing comma after the last property.

Fixed version

{
  "name": "ToolsFam",
  "type": "Browser tools"
}
Enter fullscreen mode Exit fullscreen mode

Another common mistake is using JavaScript object syntax instead of JSON:

{
  name: "ToolsFam"
}
Enter fullscreen mode Exit fullscreen mode

Valid JSON requires double quotes around keys:

{
  "name": "ToolsFam"
}
Enter fullscreen mode Exit fullscreen mode

Simple workflow

  1. Paste your JSON into a validator.
  2. Check the line where the error appears.
  3. Fix quotes, commas, brackets, or comments.
  4. Format the JSON after it becomes valid.
  5. Test it again before using it in an API request.

I wrote the full guide here:

How to Fix Invalid JSON Errors Online

Useful tools

Top comments (0)