JavaScript Formatter

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.

What is JavaScript formatting and minifying?

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.

How to use JavaScript Formatter

  1. Paste your JavaScript Enter the code in the JavaScript box. Empty input produces no output.
  2. Choose Beautify or Minify Use the Operation buttons. Beautify indents the code; Minify strips comments and whitespace.
  3. Set indent and braces For Beautify, choose Indent (2 spaces, 4 spaces, Tab) and Brace style (Same line, New line, End on new line).
  4. Review and copy Check the Formatted JavaScript pane, then copy it or download formatted.js.

Frequently asked questions

Does Minify rename variables like Terser or esbuild?

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.

Will Beautify add missing semicolons?

No. It changes indentation and line breaks only. Code that relies on automatic semicolon insertion stays that way.

Does it support modern syntax?

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.

What are the regex limitations in Minify?

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.

Is my code uploaded?

No. Formatting happens in the page and the code is not sent to a server.

Can I format TypeScript or JSX?

The tool is meant for JavaScript. TypeScript type annotations and JSX are not specifically supported.