gizmobench
BrowseDaily

JavaScript Validator

Use this JavaScript syntax checker to inspect a pasted file without executing it. Choose Auto, Script or Module and an ECMAScript version from ES5 to ES2024; ES2015 is the edition also called ES6. The first detected grammar error appears with its line, column and source frame. Change the code to check the next error, or copy the diagnostics for review. A clean result means this page’s parser accepted the supported syntax for those settings. It is not a complete JavaScript engine, runtime debugger, automatic code fixer or lint service: it does not track declarations or validate the contents of regular-expression patterns, and it refuses TypeScript and JSX.

Mode
diagnostics1 problem
6:4 error Unexpected end of input The block opened at 3:28 is never closed. 6 | } | ^ mode module (auto) ECMAScript 2024 nothing was executed
Status
Invalid
Mode
Module (auto)
Stops at
6:4
Parser
in-page 1.0

Invalid: Unexpected end of input at 6:4, read as a module against ES2024. Nothing was executed.

  • A top-level exportscript mode; module mode accepts it
    export is only allowed in module mode at 1:1
  • Unclosed brace6 lines, module mode
    Unexpected end of input at 6:4
  • A file that parsesmodule mode
    valid syntax, and nothing was executed
What is checked, and what is not. The grammar: statements and declarations, classes with private names and static blocks, every function form, patterns and defaults, template literals including the expressions inside their holes, regular expression literals and their flags, numbers down to separators and legacy octals, optional chaining, import and export, and the line breaks that end a statement. On top of the grammar it reports the early errors a reader expects: an assignment to something that cannot be assigned to, a return outside a function, a break or a continue with nothing to leave, a reserved word used as a name, a nullish operator mixed with a logical one without parentheses, and syntax newer than the ECMAScript version you picked. What it does not do is work out what a name refers to, so a repeated declaration, an assignment to a constant or a call to something that does not exist is not a syntax error here. JSX and TypeScript are named and refused rather than parsed. Nesting is followed 400 levels deep and then reported rather than risking the tab.

Up to 1,000,000 characters in one pass, read here in your browser with nothing uploaded, no account and nothing executed. The parser is this page: in-page 1.0, written for this tool, with no parser library loaded and no way to run what you paste. Auto reads the file as a module when it has a top-level import or export and as a script otherwise, and if that goal fails it tries the other one and reports the goal that parses. The mode, the version and the draft are kept on this device alone, drafts up to 200,000 characters, and the Start over button above the tool forgets them.

Accuracy. Your code is checked locally by this page’s parser and is never executed. It reports the first detected grammar error with a line and column counted from 1, for the selected script/module mode and ECMAScript edition. Acceptance is limited to the implemented grammar: declarations and name resolution are not tracked, regular-expression pattern contents are not fully validated, and TypeScript/JSX are refused. A clean result does not establish that an engine will accept the file or that the program works.

Common questions

Does this page run my code?
No, and that is the point of it. The checker reads your source as characters, turns it into tokens and matches those tokens against the JavaScript grammar. There is no eval, no Function constructor, no dynamic import and no timer in the module that does the work, and the test suite asserts that against the file itself as well as running a hostile fixture through it: a source that calls process.exit and loops forever is read, called valid and never touched again. Nothing is uploaded either. The page makes no network request of its own, there is no account and no sign-up, so a file under an agreement can be checked without leaving your tab.
What is the difference between script mode and module mode?
They are two different goals in the language specification and a file can be valid in one and not the other. A module may use import and export, and it is always in strict mode, which rules out a with statement and a legacy octal number such as 017. A classic script has no import and no export, so a top-level export is a syntax error there, and being outside strict mode it allows both of those older forms. Top-level await belongs to modules alone. Auto, the setting the page opens on, reads the file as a module when it has a top-level import or export and as a script otherwise, and if that goal refuses the file it tries the other one and reports the goal that parses, naming it in the Mode cell.
Why does it report only the first error?
Because after a real syntax error, everything a parser says about the rest of the file is a guess. Once a brace is missing, the parser no longer knows which block it is in, and the list of ten further problems that some tools print is mostly the first problem echoing. This page stops at the first one and tells you exactly where it is: the Stops at cell holds a line and a column, both counted from 1, the pane prints that line with a caret under the character, and at the end of the file it names the bracket still waiting to be closed, for example that the block opened at 3:28 is never closed while the file ends at 6:4.
What does the ECMAScript setting change?
It changes which syntax counts as valid, which is how you check a file against the oldest runtime you have to support. Optional chaining and the nullish operator arrived in ES2020, numeric separators such as 1_000 in ES2021, class fields, private names and static blocks in ES2022, async and await in ES2017, the exponent operator in ES2016 and arrow functions, classes, template literals, destructuring and modules in ES2015. The six versions on the page are ES5, ES2015, ES2017, ES2020, ES2022 and ES2024. Pick ES5 and a class is refused with the version that introduced it named in the message; pick ES2024 and everything through that edition is allowed. The version you picked is printed beside the verdict, so the answer is never version-free.
Does valid syntax mean my code works?
No. A clean result means this parser accepted the supported grammar, not that a runtime will accept or correctly execute it. Declarations and name resolution are not tracked: repeated let declarations, assignment to a const or a call to an undefined function can pass here. The contents of a regular-expression pattern are not fully validated either. Check runtime behavior, type errors and project lint rules with the tools intended for those jobs.
Can it check TypeScript, JSX or a framework file?
No, and it names what it found rather than guessing. A type annotation, an interface, an enum, a type alias, an as assertion, a non-null assertion and a generic type argument list are each reported as TypeScript with the position of the construct, and a tag where an expression should start is reported as JSX. Both are refusals on purpose: a checker that quietly accepted TypeScript would tell you a file is valid JavaScript when no browser could load it. Compile the file first and check the output, or paste the plain script body of a single-file component.
How much can I check at once?
Up to 1,000,000 characters in one pass, which is a large bundle, and nothing is ever truncated: a longer paste is refused with your size and the ceiling both quoted so you can split the file yourself. Bracket nesting is followed 400 levels deep, and past that the page says so rather than running out of stack in your tab. A minified file on one enormous line is handled the same way as any other: the pane windows the line it prints so the caret stays readable instead of printing a megabyte at you.
Is anything I paste stored?
Only on your own device, and only so the page opens where you left it. The mode, the ECMAScript version and your draft, up to 200,000 characters of it, are written to this browser under one key and are read back only by this page. Longer pastes are still checked in full, they are simply not kept. The Start over button above the tool forgets all of it, and if storage is blocked, as it is in some private windows, the page opens on its defaults and every paste is still checked.
Can I check ES6 JavaScript or an ES module?
Choose ES2015 for ES6 syntax, including arrows, classes, template literals and modules. Pick Module when checking import/export source, Script for classic scripts, or Auto to try the applicable goals. Later constructs such as optional chaining need a later edition. The mode and version are reported beside each result.
Can the checker automatically fix JavaScript errors?
No. It identifies the first detected grammar error and its source position; you edit the source yourself and the result updates. It does not invent missing code, fix runtime exceptions, track variable declarations or apply ESLint/JSHint rules.
Does it validate email addresses, URLs, JSON Schema or regular expressions?
No. Those are data or pattern-validation jobs, not JavaScript source-grammar checks. The parser does not execute your validators. Use the relevant utility or library for your data and Regex Tester for supported JavaScript regular-expression behavior.

Your code is checked locally by this page’s parser and is never executed. It reports the first detected grammar error with a line and column counted from 1, for the selected script/module mode and ECMAScript edition. Acceptance is limited to the implemented grammar: declarations and name resolution are not tracked, regular-expression pattern contents are not fully validated, and TypeScript/JSX are refused. A clean result does not establish that an engine will accept the file or that the program works.