Skip to content

SyntaxError: Unexpected end of input

Error message

                Unexpected end of input
              

Quick summary

Your code has an unclosed bracket, brace, parenthesis, or template literal — JavaScript ran out of input while still parsing.

Why this happens

  • Unclosed curly brace { without a matching }

  • Unclosed bracket [ without a matching ]

  • Unclosed parenthesis ( without a matching )

  • Unclosed template literal (backtick) without a closing backtick

Minimal example

✗ Broken code
const obj = {
  name: "Ada",
  age: 36
// missing closing brace
✓ Fixed code
const obj = {
  name: "Ada",
  age: 36
};

The object literal is missing its closing }. Adding it completes the syntax.

How to diagnose

  • Check for unmatched brackets, braces, and parentheses

  • Use an editor with bracket matching to find the unclosed pair

  • Run the code through a formatter to spot structural issues

How to fix

  • Add the missing closing bracket, brace, or parenthesis

  • Close the unclosed template literal with a backtick

  • Use a linter or formatter to identify the unclosed delimiter

How to prevent

  • Use an editor with bracket matching and auto-closing

  • Run a linter to catch syntax errors as you type

Related Resources

Related Glossary

Related Lessons

← Back to language