Common JSON Errors and How to Fix Them

Common JSON Errors

JSON is one of the most popular formats for exchanging data, but even small syntax mistakes can make an entire document invalid.

This guide explains the most common JSON errors, shows examples and provides simple solutions to help you write valid JSON.

Why JSON Errors Matter

Applications expect JSON to follow a strict syntax. A single missing quotation mark or extra comma can prevent an API request, configuration file or application from working correctly.

Learning to recognize common mistakes makes debugging much faster.

Missing Double Quotes

Property names must always be enclosed in double quotation marks.

Invalid

{
  name: "John"
}

Valid

{
  "name": "John"
}

Trailing Commas

JSON does not allow commas after the final property or array item.

Invalid

{
  "name": "John",
}

Valid

{
  "name": "John"
}

Missing Commas

Each property must be separated by a comma.

Invalid

{
  "name": "John"
  "age": 30
}

Valid

{
  "name": "John",
  "age": 30
}

Using Single Quotes

JSON requires double quotes for strings and property names.

Invalid

{
  'name': 'John'
}

Valid

{
  "name": "John"
}

Unclosed Braces or Brackets

Every opening brace or bracket must have a matching closing character.

Invalid

{
  "items": [
    1,
    2

Valid

{
  "items": [
    1,
    2
  ]
}

Invalid Data Types

JSON supports only strings, numbers, objects, arrays, booleans and null.

Functions, comments and undefined values are not valid JSON.

How to Validate JSON

The easiest way to find syntax errors is to use a JSON validator or formatter. These tools automatically detect invalid syntax and often indicate the exact line containing the error.

Tips for Writing Valid JSON

  • Always use double quotes.
  • Check commas carefully.
  • Match every opening brace.
  • Keep formatting consistent.
  • Validate JSON before using it in production.

Frequently Asked Questions

Why is my JSON invalid?

Most JSON errors are caused by missing quotation marks, missing commas or unmatched braces.

Can JSON contain comments?

No. Standard JSON does not support comments.

Can JSON use single quotes?

No. JSON requires double quotation marks.

How can I check if my JSON is valid?

A JSON formatter or validator can automatically detect syntax errors.

Related Articles

Related Tools