JavaScript Validator
Name The Line In Your Script, Not Just The Error
The validator for this JavaScript uses the same parser as the engine of the browser to parse your script. When the validator finds something wrong, it tells you what stopped it. Each message includes a line number, a column number and the token that caused the problem. So, you can find the location of the error right away. All of the scripts that you submit are kept within your browser; they are not run.
- FreePrice
- ES2024Parses
- NeverRuns code
- NoneUploads
JavaScript Validator
Read a script and name the first syntax error, with the line and the column
Nothing read yet.
Read to the end. Every line parses, and there is nothing to fix.
Ready. Paste a script, or press the sample button.
An automatic check, not a final verdict
This tool reads your code as text. It cannot run every script or test every browser, so review each finding before you delete or rewrite anything.
What A JavaScript Validator Checks
An entire script must be read by an engine before running even a single line of that script. So, if there is a broken bracket anywhere within the script, then the engine will stop reading the script and the tab will remain empty.
This is what the JavaScript validator was created for. It parses your code into text and then finds the first area where the syntax of your program is invalid, giving you the line number and the column.
The program also examines the form of the input that was processed. A non-matching pair of braces; a single quote/double quote that is not closed; a keyword used as an identifier name; an extra comma within the parameter list of a function call.
The script does not build an execution context. So, it will not create a global variable, nor will it call any functions. Since the reader is only reading the script, you can use a validator to check code that you wouldn’t use on a page of your own.
No content is allowed to leave this tab. As such, a client script that has been written under an NDA is read in the same manner as a public script.
How A JavaScript Validator Reads A Script
In the initial step, the text will be broken down into individual parts called "tokens." Each token has its own characteristics such as being a number, string, template literal, regular expression, name, operator, or keyword. The reader determines what type of token they are viewing, character-by-character.
Then the second pass goes through the tokens one by one and examines the structure of what it sees; i.e., how many brackets remain open, what scopes already exist in name, and if a word like "return" exists within a function. This part of the process is governed by ECMA-262, which is the underlying standard for all engines.
The order in which these steps take place is important because it is what causes so many unexpected error messages. For example, if you think a script you wrote is having problems with its brackets, you might actually be having problems with an unclosed quote.
One instance needs a more detailed examination as opposed to a simple "rule": a slash can represent either a division operation or the beginning of a regular expression, and the identification of which is determined by the previous token. So, the tokenizer requests info from the last token about what type of token it represented.
Template literals have added another layer of complexity. Since template literals can contain expressions within curly brackets, the tokenizer maintains a stack of the template literal(s) being processed. So, curly brackets in a string are treated as part of the string itself, whereas curly brackets in a template literal are treated as part of the program code.
Why A Valid Script Can Still Be Wrong
Grammar and meaning are separate layers. A validator answers the grammar question, and every useful one stops there.
A script may execute with a variable that has not been defined in strict mode; a script may attempt to access a property on an object that contains nothing (undefined) at the time of execution; or a script may use an await expression within a function which is not declared as async. Each of these only fails while the code is running.
The separation between the two is worthy of preservation. A syntax error indicates that the entire file was unable to run, while a runtime error signifies that the file was able to run up until the point at which the error occurred. These errors need very different approaches to debugging.
That is also why this page names the first error rather than a hundred. Because the parse stops there, everything after it is guesswork, and a list of guesses is worse than one fact.
The Six Checks The Validator Runs, Explained
The first check is whether the brackets are balanced. If the reader finds a bracket (either a curly brace, square bracket or parenthesis) that has no match where it stopped reading, then this will cause the entire file to fail.

A second is a non-terminated string or template. As the tokenizer will consume all content following an open quote, the note finds both the open quote and the point at which searching ceased (the end of the file).
The final example would be a token that is not permitted by the grammar. Examples of this include two consecutive operators, a comma placed incorrectly, and an arrow without any preceding token. For each instance of a disallowed token, the user will get the actual token.
The fourth is a reserved word that was used as a variable name. When the program begins running, the reader will decline to accept the assignment of a reserved word, as well as a variable named with one.
The fifth is a repetition within a single scope. When two parameters have the same name, or a let repeats a name previously declared in the same block, the latter will be used when the former was used first; but it will throw an error when the latter was used second. So, the reader will name both.
The sixth involves returning from a function and similar things. A "break" statement that isn’t inside a loop, a "case" statement that isn’t inside a "switch," and a "yield" statement that isn’t inside a "generator." All of those belong in only one place and no other.
What The JavaScript Validator Will Not Do
The validator does not run your script. So, nothing on this site will create a function, set a variable, or start a timer, which means that nothing on this site can be executed against the page while you are reading it.

The code won’t produce a runtime error, a type error, or a failed network request. Those types of errors need an engine, and the engine you have now is the one on the other side of your browser.
Your code is still broken. The possible missing bracket is only a comment, and not an actual correction, as an automated repair could change a obvious bug into a subtle logical change in how the software runs.
Types aren’t verified. Files that contain a type annotation have more than just JS code in them, so give the output from your compiler, not the input.
See the JavaScript Validator at Work, Start to Finish
This brief video shows each step from start to finish. Choose your language below, and switch on captions if they help.
Finding Script Errors With The JavaScript Validator
It takes four steps, and not one of them asks you to sign up.
Paste the script
You can either copy an entire file or just one function. The reason for this is that the reader processes your code as text (not compiled), so a small portion of your code is acceptable if it contains balanced brackets.
Pick the source type
The user can then select either a script or a module. The selection will work out whether the user views the use of import and export as correct or incorrect, because imports and exports are part of a module.
Read the first note
The next step is to move the cursor to the row and column listed above. Since the parser has stopped after the first failure, the subsequent note is a result of the first failure, not another failure.
Fix, re-run, then carry on
Finally, edit in your own editor and paste it back to confirm the count is zero. After that, the file is ready for the minifier or for the browser.
Reasons To Use This JavaScript Validator
Five reasons, and each one saves a debugging session.
It points to a line and a column
Because the note has both characteristics, you can focus on the character and not on the whole area. So, a two hundred line file is a quick scan instead of a search.
It explains why the parse stopped
A note describes the expected grammar for a particular point in the text. As such, it is normally clear how to correct the error based on the note alone and doesn’t need another person’s view.
Nothing executes
A validator is where you should paste a script that has been written by someone else because that script is only being read and cannot run as long as you are viewing it.
Nothing uploads
This is where the parse will occur. So, it is acceptable to paste a file that has been obtained from a private repository.
It reads modern syntax
Since the grammar is based on today’s standards, we can use an arrow function, an optional chain and a class field. So, a modern file is not flagged as modern because it uses modern features.
Habits That Keep A Script Parsing
Six habits that keep a script easy to read and quick to validate.
- Close the bracket as you open it The partner will have been present before the time you completed the center part of the form. This is an extremely common type of error that has been removed by a very small habit.
- Write in strict mode Strict mode is the standard behavior for modules, and you can enable this mode in scripts through a directive at the top of the file. As strict mode converts many silent mistakes into errors, your JavaScript engine will stop when it encounters one instead of continuing to run.
- Prefer const, then let Variables defined within a single block belong to the entire function. This means that variables may unintentionally use the same name. As a result, even though they appear to be two different variables, they could actually be only one variable.
- Keep one statement per line An engine adds semicolons if you don’t use them, but it may not be correct about what you intended. With only one line used for each statement there isn’t any confusion, so the reader doesn’t have to guess.
- Validate before you minify A minifier trusts its input, so a broken script comes out broken and harder to read. Hence check the readable file first, where the line numbers mean something.
- Paste the compiled output The compiler must be run before checking what was produced, since a type annotation is not part of JavaScript and thus a file containing a type annotation will fail to parse.
Six Ways A Script Fails To Parse
Each one of the above causes the entire file to be stopped and so so none can be overlooked after they occur.
Brackets closed in the wrong order
Watch out for this. The engine finds a non-matching pair instead of a missing mark. So, the note points to the incorrect-appearing line instead of the incorrect line.
A quote inside a string of the same kind
If a quotation is unescaped, it will end the string early. The parser will then read the rest of the line as code. So, the error will be located further down in the program than where the problem occurred.
A slash that means division
Two lines down from a missing semicolon, a slash can start a regular expression instead of dividing. Hence one missing mark turns into a confusing error about a pattern.
A template literal left open
A backtick left open swallows the rest of the file. So the note names the opening backtick and the end of the input rather than the line you meant to fix.
A comma standing where a semicolon belongs
Inside an object a comma is right and inside a block it is wrong. Because the two look alike at a glance, this one survives a careful read.
A reserved keyword used as the name of a variable
A name that worked in one file may be an error in the next because class or default parses in only one of two positions.
JavaScript Validator Questions
Is this JavaScript validator free?
Yes. You never sign up, never hit a cap and never meet a paywall. So you validate as many scripts as you like.
Will the validator run my code?
Never. The reader reads the script as text, parses the script as text, and doesn’t call any functions. So, a stranger’s snippet of code won’t run while you’re reading it.
What does it check?
The six families are bracket balance; unclosed strings and templates; tokenization rules that the parser cannot process; naming variables after reserved words; having duplicate names in a single scope; and placing return, break, or yield in an inappropriate location.
Which version of JavaScript does it accept?
The current standard is up to ES2024. This means that a standard arrow function, optional chaining, a class field, and top-level await in a module can be parsed.
Does it find runtime errors?
No. A runtime error needs a program to execute the code, and that’s not what we’re asking for here. We are solely answering the question about the grammar.
Why does it report only one error?
The parse will stop when it encounters an error. Beyond this point, it’s all guesswork. It is better to have one concrete piece of info, rather than a hundred assumptions.
Is the script I paste sent to a server?
The entire check runs in the current browser tab, which means that any script running under a non-disclosure agreement will remain in the location that you have put it.
Can I validate a fragment rather than a whole file?
Yes, a single function can work if the bracket matching is correct. The lines of code that you paste will have line number references.
Does it understand JSX or TypeScript?
No, because they are not JavaScript but rather extensions. So, you should compile the code before running the validation check on the output of the compilation process.
How does a syntax error differ from a type error?
A syntax error indicates that none of the file was processed. A type error occurs during program execution on a line that was successfully parsed. So, each of these types of errors need a distinct approach to debugging.
Does the validator check browser support?
No. A statement can be valid and still do nothing in the browser that matters. Grammar and support are separate questions.
Can it fix the error for me automatically?
No, we omitted it for a reason. An automated correction could transform a very obvious error into an unnoticeable change in behavior, which would be more difficult to find than the note itself.
Why is my code flagged for a slash?
A slash is division or the start of a regular expression, and the answer depends on the token before it. Without a semicolon in the right place the reader has to pick one, and the note says which.
Will it check a module?
Yes. When you choose the module source type, then both importing and exporting are allowed, but when you use a simple script then both importing and exporting will cause an error. A module will also treat let, static and yield as being "reserved", so a name which passes when used in a script may not pass when used in a module.
Can I validate a minified file?
Yes, but the line numbers have little use. Since a minified file is typically just one continuous line, you must return to the legible source to find your solution.
Does it count anything?
The summary includes line counts, token counts, and character counts that will help you work out if your paste was cut off before it finished.
Is it the same as a linter?
No, a linter is designed to find stylistic issues and unused variables that the parser has no interest in. Thus, a successful run through this tool means that the code compiles (or parses) and that’s all.
Does it run on phones too, or only on desktops?
Yes. The panes stack and the notes wrap. So you can run a quick check from a phone, though a long file is easier on a keyboard.
Can I download the validator notes?
Yes, the download creates a text file containing the notes, making it convenient for a user who needs the exact line numbers of a particular ticket.
Is an account or a browser add-on required?
No. You have no need to sign up, use a plug-in or install an extension. When the script has finished parsing, then close the tab.
Handy Companion Tools For This Job
Four pages the same job usually leads to.
- JavaScript minifier
The first step is to remove all white spaces and comments from the script after it has been parsed. As long as you are downloading every single byte, it is best to minify the script once it has been validated instead of before validation.
- Code beautifier
A file that has been parsed correctly may still be unreadable. So, please reindent the code and work out your preferred coding style for braces before the next review.
- JSON formatter
Most script failures here come from data rather than logic. So unfold the payload and check it parses too.
- CSS validator
The other half of a front-end build. Because the browser drops a declaration with a typo in silence, that sheet deserves the same check.
Find The Line The Engine Would Refuse
Paste the script, read the first note, fix it and run it again. Nothing executes and nothing uploads. Most files parse before the kettle boils, and the note tells you which character to look at.