
How to Unminify JavaScript for Debugging (Readable Output)
Learn how to unminify minified JavaScript for debugging. Transform unreadable code into formatted, understandable code in just a few clicks with our free tool.
The problem with minified code in production
You've probably encountered this situation: a JavaScript error appears in production, but the source code is minified and completely unreadable. Variables are renamed to `a`, `b`, `c`, spaces removed, comments erased. How do you debug in these conditions? The solution: unminify the code to make it readable and understandable.
Best practices for debugging minified code
Here are proven techniques for effectively debugging minified code:
Even with renamed variables, you can identify problems:
Why unminify JavaScript?
Several situations will lead you to unminify JavaScript:

It's important to understand what unminification can and cannot do:
Limitations:
What works:
How to unminify JavaScript with FastMinify
The simplest and fastest way to unminify JavaScript is to use an online tool like FastMinify.
1Copy the minified code
Copy the minified JavaScript code from the browser console, DevTools, or a source file.
2Paste into FastMinify
Go to [FastMinify - Unminify JavaScript](https://fastminify.com/en/minify-js) and paste your code in the left editor.
3Click "Unminify"
Select the "Unminify" option in the processing options. The formatted code will appear instantly in the right editor.
4Copy the result
Copy the unminified code and use it for your debugging or analysis.
Example:
Before (minified):
function a(b,c){return b+c}const d=a(5,3);console.log(d);After (unminified):
function a(b, c) {
return b + c
}
const d = a(5, 3);
console.log(d);Here's a real example of how to unminify code to debug an error:

Minified code:
!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return ...Unminified code (preview):
!function(e, t) {
"object" == typeof module && "object" == typeof module.exports
? module.exports = e.document
? t(e, !0)
: function(e) {
if (!e.document)
throw new Error("jQuery requires a window with a document");
return t(e)
}
: t(e)
}("undefined" != typeof window ? window : this, function(e, t) {
var n = [],
r = e.document,
i = n.slice,
o = n.concat,
s = n.push,
a = n.indexOf,
u = {},
c = u.toString,
l = u.hasOwnProperty,
f = {},
p = "2.3.1",
d = function(e, t) {
return new d.fn.init(e, t)
},
h = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
// ... rest of formatted code
});Using Source Maps for optimal debugging
Source Maps are files that establish a mapping between minified code and original source code. This is the best solution for debugging minified code.
To enable Source Maps in your build:
Terser
const terser = require('terser');
const result = await terser.minify(code, {
sourceMap: {
filename: 'app.min.js',
url: 'app.min.js.map'
}
});Webpack
module.exports = {
devtool: 'source-map', // For production
// or 'hidden-source-map' to not expose publicly
optimization: {
minimize: true,
minimizer: [new TerserPlugin({
sourceMap: true
})]
}
};Debugging with browser DevTools
Chrome DevTools includes a "Pretty Print" feature that automatically formats minified code.

Once the code is unminified (via FastMinify or Pretty Print), you can:
Tips:
Best practices for debugging minified code
Here are proven techniques for effectively debugging minified code:
Even with renamed variables, you can identify problems:
Alternative tools for unminifying
Several tools allow you to unminify JavaScript. Here's a quick comparison:
FastMinify
Free, fast online tool with no registration required. Also supports minification and beautify.
Pros:
JS Beautifier
Popular open-source tool for formatting and unminifying JavaScript.
Pros:
Cons:
Prettier
Popular code formatter that can also format minified code.
Pros:
Cons:
Try our free minification tools to optimize your code:
Conclusion
Unminifying JavaScript is an essential skill for any developer working with production code. Whether you use FastMinify for a quick solution, Source Maps for optimal debugging, or browser DevTools, the important thing is understanding how to transform unreadable code into understandable code. Remember: the best solution remains having Source Maps in production for optimal debugging.
Related Articles
Understand the differences between online minifiers and build tools. Learn when to use each approach to optimize your development workflow.
Discover why Google favors fast sites in search results. Understand the link between web performance and SEO, and learn how to optimize your site to improve your ranking.
Learn how to enable GZIP and Brotli compression on your Apache and Nginx servers. Step-by-step tutorial for all levels, with ready-to-use configurations and verification tools.