JavaScript Minifier
Minify and compress JavaScript code
Esta es una minificación básica. Para producción, usa herramientas como Terser, UglifyJS o el minificador de tu bundler.
Minificador JavaScript
Reduce el tamaño de tu JavaScript eliminando comentarios, espacios y saltos de línea innecesarios.
Online JavaScript Minifier - Compress and Optimize JS Code
How does JavaScript minification work?
JS minification goes well beyond stripping spaces. It removes comments and whitespace, shortens local variable names (userName becomes a), eliminates dead code, folds constant expressions, strips console.log calls for production, collapses variable declarations, and converts property access to dot notation where possible. The result is functionally identical but unreadable to humans, which also provides a basic layer of obfuscation. Advanced minifiers such as Terser routinely cut code by 60 to 70%.
Minification, uglification and tree shaking: the difference
Minification reduces size by removing unnecessary characters and shortening names. Uglification, a term from UglifyJS, means minification plus transformations that make the code harder to understand, a light form of obfuscation. Tree shaking is a modern bundler optimization that drops unused code: if you import a single function from a library, tree shaking discards the rest. These techniques complement each other, and a modern build pipeline built on Webpack, Vite or Rollup applies tree shaking during bundling and minification at the end.
Security considerations and source maps
Minification is NOT security. Even though the code is hard to read, any determined developer can beautify it and follow along. Never ship secrets such as API keys or passwords in client-side JavaScript, minified or otherwise. For debugging in production, use source maps: .map files that tie the minified code back to the original, which DevTools will use to show you the real source. In production you can serve source maps only to authenticated users, or not publish them at all.
If you work with this tool, you will probably also find these useful SVG Optimizer, JSON Formatter, YAML/JSON Converter, Markdown Preview.
Frequently asked questions
Can minification introduce bugs?
Very rarely with modern minifiers such as Terser. Trouble can appear when code depends on function names through reflection, contains syntax bugs the browser happens to tolerate, or uses eval() with dynamically generated code. Always test minified code before deploying, and use source maps to tell whether a bug lives in the original or was introduced by the build.
Why is my minified code still large?
A few possible reasons: the original carries a lot of logic that simply cannot be reduced, you are bundling entire libraries when you use only part of them, tree shaking is not enabled, or there is a lot of duplicated code. Consider a bundler with tree shaking, import only what you need (import { map } from lodash-es rather than the whole of lodash), and prune unnecessary dependencies.
Should I minify code that already goes through a bundler?
If your bundler is configured for production it already minifies automatically, so extra minification adds nothing. This tool is useful for standalone scripts without a build pipeline, for legacy code, or for checking what the minified output looks like before you configure a bundler.
Does the minifier support ES6+ and TypeScript?
This tool supports modern JavaScript including ES6 and later: arrow functions, destructuring, template literals, classes and async/await. TypeScript must be compiled to JavaScript with tsc first, then minified. Modern bundlers handle TypeScript compilation and minification in a single step.