// IT TOOLS & CALCULATORS
| 100+ TOOLS
⚡ JS FORMATTER & VALIDATOR100% Free
// Validate JavaScript syntax, prettify and compact JS — real parser errors, not guesses
ADVERTISEMENT
[ IN-CONTENT AD ]

JS Formatter / Validator

Paste in minified, generated or hand-edited JavaScript and get back something indented and readable. Validation here uses the browser's own JavaScript engine to parse the code — the same parser that would run it — so a syntax error is a real one, not a guess from a regular expression pattern that happens to look like JavaScript.

How the validator actually works

The check constructs your code as a function body using JavaScript's built-in Function constructor and catches the parse error if there is one — the function is never called, so nothing in your code actually runs, only parses. This catches genuine syntax errors: a missing closing brace or parenthesis, a stray comma, an unterminated string, invalid syntax anywhere in the code. It won't catch a logic bug (code that runs but does the wrong thing) — no static tool can, without actually running it against real inputs — and it doesn't accept top-level import/export module syntax, since that's only legal at the top of an actual module file, not inside a function body. Everything else — variable declarations, functions, classes, loops, conditionals, async code — parses exactly as it would in a real script.

What beautify and compact do, honestly

The formatter here reindents based on brace, string and comment boundaries — it reformats structure reliably for typical minified or compressed code, but it isn't a full JavaScript parser rebuilding an abstract syntax tree the way a tool like Prettier does, so unusual formatting choices (a single-line arrow function packed with nested ternaries, for instance) may come out serviceable rather than perfectly idiomatic. Compact strips comments and collapses whitespace down to single spaces without renaming variables or removing safe-to-drop syntax — it shrinks the file honestly without gambling on identifier-mangling minification, which is a different, much riskier problem that dedicated build-time tools (Terser, esbuild) are built to solve correctly.