JSON Reference Guide

Common JSON Syntax Errors and How to Fix Them

JSON (JavaScript Object Notation) is the standard format for data exchange on the modern web. While it looks simple, its structure is strictly defined. Even a single misplaced character will fail parsing in engines like JavaScript's JSON.parse(), throwing cryptic exceptions. Learn why these common errors happen and how to resolve them instantly.

1Trailing Commas

In modern JavaScript, writing trailing commas after the last element in an object or array is considered a best practice because it makes Git diffs cleaner. However, the JSON specification strictly forbids trailing commas. Having a comma after the final key-value pair or list item will cause parser failures in almost all environments.

Wrong (Trailing Commas)
{
  "name": "Quietbench",
  "tools": ["formatter", "regex",],
}
Correct
{
  "name": "Quietbench",
  "tools": ["formatter", "regex"]
}

2Single Quotes Instead of Double Quotes

Unlike JavaScript or Python where single quotes (') and double quotes (") are interchangeable, the official JSON standard (RFC 8259) requires all strings, key names, and string values to be wrapped in double quotes. Single quotes are syntactically invalid JSON.

Wrong (Single Quotes)
{
  'status': 'active',
  'message': 'Success'
}
Correct
{
  "status": "active",
  "message": "Success"
}

3Unquoted Keys

In standard JavaScript objects, keys do not require quotes unless they contain special characters or spaces. In JSON, however, every object key must be a valid string wrapped in double quotes. Leaving keys unquoted will result in an immediate parsing error.

Wrong (Unquoted Keys)
{
  host: "localhost",
  port: 8080
}
Correct
{
  "host": "localhost",
  "port": 8080
}

4Missing or Mismatched Brackets/Braces

JSON structures rely heavily on matching curly braces {} for objects and square brackets [] for arrays. When nesting arrays within objects or objects within arrays, it is extremely common to miss a closing tag, or close an array using a brace. Double-check that every opening bracket or brace has its corresponding closing tag at the correct indentation level.

Wrong (Missing Closing Brace)
{
  "db": {
    "url": "postgresql://localhost:5432"
  // Missing closing brace for "db" or main object
Correct
{
  "db": {
    "url": "postgresql://localhost:5432"
  }
}
Getting a Python error instead? See our guide on the "must be str, bytes or bytearray" TypeError.
Need the deep dive on trailing commas? Why JSON forbids trailing commas (RFC 8259)

Struggling to locate a JSON syntax error?

Validate your payload instantly. Our browser-based tool finds syntax errors and highlights exact line numbers.

Use our free JSON Formatter to validate and fix your JSON instantly