JavaScript syntax validator
Paste your code and check whether the JavaScript engine can compile it. The validation does not run the programme: it simply analyses the syntax and highlights practices that are worth reviewing.
Workspace · JavaScript Validator
No se ejecuta: solo se compila para detectar errores de sintaxis.
- Hay llamadas a console: recuerda quitarlas antes de publicar.
How to use it
Paste the code into the text box.
Check the status: if the syntax is valid, you will see a green indicator; if not, you will see an error message and the approximate line number.
Please note the additional warnings regarding console, debugger, eval, document.write, var and double-equal comparisons.
Examples
Closing error
A function without a closing brace raises a SyntaxError, and the validator indicates this by showing the position of the error.
Valid code with warnings
A correct block that still contains `console.log` is marked as valid, but remember to remove the logs before publishing.
What you need to know
The check creates a function using `new Function`, which forces the engine to analyse the code without executing its body. It is a quick way to detect misplaced curly brackets, brackets, commas and keywords, but it does not check for types, non-existent variables or runtime errors.
Code containing ‘import’ or ‘export’ statements belongs to an ES module and cannot be validated using this technique. In such cases, the validator will issue a warning, and it is advisable to use the project’s bundler or compiler, which do understand the modular syntax.
Frequently Asked Questions
Related tools
Other tools that can help with similar tasks.
JavaScript Formatter
Indent and organise JavaScript code so that it can be reviewed easily.
CSS Validator
Find properties or values that the browser does not recognise, and unclosed keys.
JSON formatter and validator
Formats, validates and organises JSON with error detection.
