JavaScript formatter

Beautify or minify JavaScript.

Mode
Indent

0 lines · 0 characters

0 lines · 0 characters

Results update as you type.

Runs in your browser. Nothing uploaded.

How to format JavaScript

  1. Paste your code into JavaScript, such as a minified file or a snippet copied from your browser.
  2. Keep Format selected and choose 2 or 4 spaces. Choose Minify to compress the code instead.
  3. Copy the result or download it as a .js file.

What formatting changes

  • Each statement goes on its own line, and blocks inside braces are indented one level.
  • Spaces are added around operators and after commas and keywords, so if(a>b){ becomes if (a > b) {.
  • Blank lines you had are kept, but several in a row become one.
  • Names, strings, comments and the order of the code don’t change.

Reading third-party code

Formatting is the quickest way to read a minified script: a library bundle, a tracking snippet or code you found while debugging a site. Once it’s indented you can follow the control flow, even with one-letter variable names. Minified code is not hidden code, so anything shipped to the browser can be read this way.