Common syntax errors and what they mean

MessageUsual cause
Unexpected token '}'A missing opening brace or an extra closing one, often after editing an if block
Unexpected end of inputAn unclosed {, (, string or template literal
Invalid or unexpected tokenSmart quotes pasted from a document (“ ” instead of "), or a stray character
missing ) after argument listA missing comma or parenthesis in a function call
Identifier 'x' has already been declaredTwo let or const declarations of the same name in one scope

Because the check uses new Function(), top-level import/export statements are reported as errors even in valid modules; remove them to check the rest. To format the code after it parses, use the JavaScript beautifier; to check JSON, use the JSON validator.

Javascript Playground

Paste JavaScript to test whether it parses. The code is checked, never executed.

What you can do here

How the JavaScript tester works

The code is handed to the browser's own JavaScript engine with new Function(code), which compiles it without running it. If it compiles, you see "Valid JavaScript"; if not, you get the engine's error message, such as Unexpected token '}'. Because nothing is executed, it is safe to test an unfamiliar snippet here.

Common questions

Does this playground run my code?

No. It checks syntax only, which makes it safe for untrusted snippets. To run code, use your browser's developer console.

Why is valid ES module code reported as an error?

import and export are only allowed in modules, and new Function compiles a normal function body. Remove them to test the rest.

Is my code uploaded?

No. Everything happens in your browser.