Beautify or minify JavaScript.
The JavaScript Formatter beautifies minified or messy JavaScript into readable, indented code, and can also minify code by stripping comments and whitespace. You choose the indent style and where opening braces go.
JavaScript is mostly whitespace-insensitive, so the same program can be written in a compact single line or in a clearly indented layout. Beautifying re-indents the code and puts statements on separate lines, which is how you read bundles, snippets copied from a browser console or code that came through a build step. Minifying removes characters that the engine does not need, mainly comments, spaces and line breaks, to make the file smaller. Real production minifiers also rename variables and rewrite expressions; this tool does not. It only strips comments and whitespace, keeps strings, template literals and regular expression literals as written, and keeps line breaks that could matter for automatic semicolon insertion. Beautify uses the js-beautify library.
No. It only removes comments and unnecessary whitespace. Names, structure and logic are unchanged, so the size reduction is smaller than with a full minifier.
No. It changes indentation and line breaks only. Code that relies on automatic semicolon insertion stays that way.
The beautifier handles common modern syntax such as arrow functions, classes, template literals and async/await. It does not validate the code, so a syntax error is simply formatted as written.
The minifier decides whether a slash starts a regex by looking at the previous token. A regex directly after a closing parenthesis, bracket or brace is treated as division, so its internal spaces may be collapsed. Most real code is unaffected, but review unusual code.
No. Formatting happens in the page and the code is not sent to a server.
The tool is meant for JavaScript. TypeScript type annotations and JSX are not specifically supported.