gizmobench

JavaScript Validator

Paste a file and this page answers one question: does this parse as JavaScript? When it does not, the first syntax error comes back with its line, its column and the line of source it sits on, a caret under the character that stopped it, and, when a bracket is to blame, the position of the bracket that never closed. Two things are different here. The page says which JavaScript it is checking against: a mode, script or module or Auto, and a language version from ES5 to ES2024, both shown beside the verdict, so a refusal always has a standard behind it rather than being one tool's opinion. And it says what it did not do. Nothing is executed at any point: the parser was written for this page, there is no eval, no Function constructor, no dynamic import and no timer anywhere in it, and the pane repeats that under every verdict, because the reason to paste a file into a checker is usually that you do not want to run it.

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 parsed in your browser by a parser written for this page, and it is never executed, so pasting something you do not trust is safe here. It answers one question exactly: does this text parse as JavaScript in the mode and language version you picked, and it stops at the first syntax error and names its line and column, both counted from 1. Valid syntax is not working code: JSX and TypeScript are named and refused rather than parsed, the pattern inside a regular expression literal is read only far enough to find its closing slash, and declarations are not tracked, so a repeated let, an assignment to a const or a name that was never defined is not a syntax error here.

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. Syntax is only the shape of the text. This page does not work out what a name refers to, so a variable declared twice, an assignment to a constant and a call to a function that does not exist all parse happily here and fail the moment they run. It also reads the inside of a regular expression literal only far enough to find the closing slash, so an unbalanced group inside a pattern passes here and a JavaScript engine refuses it. What a green verdict does tell you is real and often what you need: the file is complete, no bracket or quote is unclosed, and it will parse in the mode and version you chose.
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.

Your code is parsed in your browser by a parser written for this page, and it is never executed, so pasting something you do not trust is safe here. It answers one question exactly: does this text parse as JavaScript in the mode and language version you picked, and it stops at the first syntax error and names its line and column, both counted from 1. Valid syntax is not working code: JSX and TypeScript are named and refused rather than parsed, the pattern inside a regular expression literal is read only far enough to find its closing slash, and declarations are not tracked, so a repeated let, an assignment to a const or a name that was never defined is not a syntax error here.