JavaScript Beautifier

Reformat minified or messy JavaScript into readable code.

Minified JavaScript is technically readable in the way a phone book is technically a story. Beautifying it restores line breaks and indentation, which is the first step in understanding code you did not write.

Formatting JavaScript

  1. Paste the minified or poorly formatted code.
  2. Choose your indentation.
  3. Format it.
  4. Read through the structure, which is now visible.
  5. Copy what you need into your editor.

What you get back and what you do not

You get back the structure: function boundaries, nesting, control flow, and the shape of the logic. That is usually enough to follow what a script is doing.

You do not get back the names. A minifier renamed every local variable to a single letter and that information is gone permanently. Nor do you get the comments. So expect readable but anonymous code — something like function t(e,n){return e.map(...)}. If the file has a published source map, that will get you much closer to the original.

When this is genuinely useful

  • Working out what a third-party script on your site actually does.
  • Auditing a tag or widget before you let it near production.
  • Debugging a bundle where the source map is missing or broken.
  • Learning from a library implementation when the repository is unavailable.
  • Checking whether an inherited script is doing something it should not.

A word on other people’s code

Reading minified JavaScript that a site serves to your own browser is ordinary debugging, and auditing scripts running on a site you are responsible for is straightforward good practice. Just bear in mind that the code is still covered by whatever licence it was released under — reading it is one thing, redistributing it is another.

JavaScript formatting questions

Can I recover the original source from minified JavaScript?

You recover the structure and the logic, but not the original variable names or comments. Those were discarded during minification. A published source map is the only way to get genuinely close to the original.

Does formatting change how the code runs?

No. Only whitespace is adjusted, and JavaScript ignores it. The one thing to watch for is that badly written code relying on automatic semicolon insertion can be fragile, though a good formatter preserves the existing semantics.

What is a source map?

A file that maps the minified output back to the original source, so devtools and error trackers can show you real filenames and line numbers. If one is available, use it rather than beautifying by hand.

Why are all the variables single letters?

Because the minifier renamed them to save bytes. Local names are invisible outside their scope, so shortening them is safe and saves a great deal of space. The original names are not recoverable.

Is my JavaScript sent to a server?

Yes. Your code is sent to our server for formatting, but it is not stored after processing.

Cookie
We care about your data and would love to use cookies to improve your experience.