Explain Codes LogoExplain Codes Logo

Tool to Unminify / Decompress JavaScript

javascript
unminification
javascript-beautifier
debugging
Anton ShumikhinbyAnton Shumikhin·Mar 8, 2025
TLDR

To unminify JavaScript code instantly, use the Pretty Print feature in Chrome DevTools or the uglify-js package if you're on Node.js:

  1. Hit F12 to open DevTools, navigate to the Sources tab.
  2. Choose your minified .js file.
  3. Click the {} button at the footer to prettify it.

Alternatively, you can use this command in your terminal:

npx uglify-js yourFile.min.js -b -o beautifiedFile.js

Now, let's move into some unminification in-depth knowledge.

Detailed Unminification Methods

Handy Online Tools

Numerous online tools like JSBeautifier.org provide a rapid and easy-to-use solution to turn your minified code into a clean & readable structure:

  • Use JSBeautifier.org to enter your code and hit the magic 'Beautify' button.

Inside Your Browser

Modern browsers come equipped with features for developers that include unminifying JS:

  • Firefox users can use the toSource method to unminify JavaScript.
  • IE9 and latter versions also support JavaScript unminification in their F12 developer tools.

These features are powerful allies during real-time debugging or routine in-browser development.

Command-line Magic

For those who love the terminal or deal with multiple files, unminification becomes even cooler with JSBeautifier:

# And now, your 'abracadabra' moment... js-beautify -r -o formatted.js minified.js

This command unminifies and replaces (-r) the minified file with the unminified version.

Extra Tidbits to Keep in Mind

Debugging with Source Maps

Source maps allow us to match the minified nightmare to the nice unminified code:

  • Developers can use source maps for advanced debugging tasks.

Handling Complex Minifications

Sometimes, minified code can be nastily optimized:

  • If you encounter an IIFE (Immediately Invoked Function Expression) that's messing things up, wrap it in {} before going for pretty print.