JavaScript Formatter
Beautify minified or inconsistently formatted JavaScript with configurable indent and quote style.
What is JS Formatter?
A JavaScript beautifier for reading code you did not write: a vendor file, a minified bundle, a snippet from a bug report. It normalises indentation, spacing and quotes without renaming or evaluating anything.
How it works
The tokenizer separates comments, strings, template literals, regular expressions and punctuation, so a `//` inside a URL or a `/` in a division is never confused with a comment. The printer then re-emits the tokens with consistent indentation, breaks after braces and statement terminators, and keeps the author's line breaks where they already exist.
- Paste the source. Drop in code, a stylesheet, a query or a selector list. Everything is read locally — the page never uploads what you paste.
- Choose the options. Indent width, quote style, keyword case or target browsers. The result updates as you change them, so you can see the effect immediately.
- Copy or download. Copy the result to the clipboard or download it as a file. Reset clears the form and returns every option to its default.
Examples
A minified vendor file
One 9,000-character line becomes an indented file you can actually step through in a debugger, with template literals and regexes still exactly as written.
A snippet pasted from a terminal
Tabs, mixed indentation and stray trailing spaces normalise to a consistent 2-space layout before you commit it.
Common mistakes
Expecting a formatter to fix invalid code
Formatting is whitespace and quoting. A missing brace, an unclosed tag or an unquoted variable survives the round trip and is reported instead — check the findings list.
Minifying without running the tests afterwards
Even a safe, non-mangling minifier can expose an existing automatic-semicolon-insertion bug. The JavaScript Minifier keeps the newlines that matter, but re-run your tests before shipping.
Treating a rewritten query as verified
The SQL Dialect Converter translates the syntax it can prove; data types, casts and function differences are listed for review, not guessed. Run the converted query against a real database.
Renaming or reformatting generated files
Regenerating a formatter's output is a no-op only if the formatter is the same one that produced it. Keep generated code out of the round trip and format the source it came from.
Frequently asked questions
Does the quote option ever change behaviour?
It only rewrites a literal when the swap is provably safe: single → double (or the reverse) happens only if the string contains neither the target quote nor a backslash escape. Anything else is left untouched.
What does “add semicolons” actually do?
It appends a semicolon to lines the source ended with a newline, skipping object properties, block openers, operators and comments. It never removes an existing semicolon — the `keep` setting does nothing at all.
Is my code sent anywhere?
No. The tokenizer and printer run in this page. Nothing is uploaded, and the tool keeps working with the network switched off.