Your files stay on your device

# JavaScript formatter

Pretty-print JavaScript with two spaces, four spaces, or tabs, or minify it to one line, using a string and comment aware scanner rather than a full parser.

Paste some JavaScript to see it formatted.

This is a token scanner, not a parser. Strings, template literals (including $ {...} expressions), regex literals, and comments are copied through verbatim, and keywords keep their case. Statements that relied on a newline for automatic semicolon insertion after return, throw, break, continue, or yield get an explicit semicolon so the output keeps its meaning. A clean run is a good sign, not a guarantee that the code would parse; exotic syntax may come out imperfect.
Options

## More regex & cron tools

- [JSON formatter](/json/formatter)
- [Regex tester](/dev/regex-tester)
- [Semver compare](/dev/semver)
[All regex & cron tools](/dev)

Was this tool useful?
YesNo

---

Canonical HTML: https://nutter.tools/dev/javascript-formatter
Markdown version: https://nutter.tools/dev/javascript-formatter.md
Plain-text version: https://nutter.tools/dev/javascript-formatter.txt
Agent index: https://nutter.tools/llms.txt

