</>
ValidateHTML

Unclosed Bracket or Brace in JSON

Every opening brace { must have a matching closing brace }, and every opening bracket [ must have a matching closing bracket ]. An unclosed bracket usually means you forgot to close a nested object or array, or you accidentally deleted a closing character.

Why It Matters

The parser reaches the end of the document expecting more content. The error message usually says 'unexpected end of input' which can be confusing because the actual problem is a missing bracket somewhere earlier in the document.

Common Causes

  • Forgetting to close a nested object or array deep inside the document.
  • Closing an array with a brace } or an object with a bracket ], so the counts never balance.
  • Accidentally deleting a closing } or ] while editing, often during a copy-paste or merge.

Code Examples

Invalid JSON
{
  "users": [
    {
      "name": "Alice",
      "age": 25
    },
    {
      "name": "Bob",
      "age": 30
  ]
}
Valid JSON
{
  "users": [
    {
      "name": "Alice",
      "age": 25
    },
    {
      "name": "Bob",
      "age": 30
    }
  ]
}

How to Fix

  • 1Use an editor with bracket matching to find unmatched brackets and braces.
  • 2Indent your JSON properly. Mismatched brackets become obvious with correct indentation.
  • 3Count opening and closing brackets. The numbers must match for both {} and [].
  • 4Start from the error position and work backwards to find the unclosed structure.

Frequently Asked Questions

Why does the error say unexpected end of input?
The parser read the whole document still waiting for a closing brace or bracket that never came. The missing character is usually far earlier than the end, so start from the last correctly closed structure and look for what stayed open.
How do I find which bracket is unclosed?
Format the JSON with proper indentation, then use an editor's bracket-matching feature. A mismatched indent level or an unmatched { or [ becomes obvious. Counting opening versus closing characters of each type also pinpoints the imbalance.
Can a closing brace fix an array, or do I need a bracket?
An array must close with ] and an object must close with }. They are not interchangeable. Closing an array with } produces a structure error even if the totals happen to match.

Check Your JSON Now

Our JSON validator detects this error automatically and shows the exact line and column.

Open JSON Validator
Recommended

Cloudways · Managed Cloud Hosting

Fix this JSON error, then deploy on Cloudways managed cloud (AWS, GCP, DigitalOcean).

Free 3-day trial · 30% off 3 months + free site migration with code MIGRATE303

Start free trial

Related JSON Errors

View all JSON errors