Minificador JavaScript online y gratuito
El minificador JavaScript elimina comentarios y espacio en blanco innecesario de tu JS para reducir el tamaño del archivo. No tiene dependencias, respeta cadenas y expresiones regulares, y sirve para el código del día a día.
The result is worth sanity-checking with the JavaScript Obfuscator, which is the aggressive end of the same idea, and its structure can be reviewed with the JavaScript Minifier run in the opposite direction. For the stylesheet alongside it, the CSS Minifier is the counterpart.
Cómo usar Minificador JS
- 1 Paste your JavaScript, or load a file.
- 2 Choose whether to strip only whitespace and comments, or to also rename local variables.
- 3 Check the reported saving and any warnings.
- 4 Test the output. Minification can change behaviour if the code relied on variable names.
Cómo usarlo
Pega tu JavaScript y pulsa Minimizar. La versión compacta aparece a la derecha.
- Elimina comentarios // y /* */
- Conserva cadenas y expresiones regulares
- Mantiene un espacio entre identificadores contiguos para evitar que se fusionen
Nota sobre el alcance
Es un minificador ligero que funciona en el navegador. Para builds de producción con optimización completa (eliminación de código muerto, mangling), usa un empaquetador como esbuild o Terser.
Preguntas frecuentes
What is the difference between minifying and mangling?
Minifying removes whitespace and comments, which never changes behaviour. Mangling renames local variables and function parameters to short identifiers, which reduces size further but requires analysing scopes correctly. Mangling is where most breakage happens, and it is also where most of the size saving comes from.
Why did my code stop working after minifying?
The most common cause is reliance on a function's declared name or argument count. Code that calls `toString()` on a function to inspect its name, or uses `arguments.length`, behaves differently once names are changed. So does anything using `eval`, which cannot be analysed statically and therefore cannot be mangled safely.
Should I minify my own build output?
Use a proper bundler instead. Minification is one step in a pipeline that should also resolve modules, tree-shake unused exports and handle the target environment. A standalone minifier is useful for checking what a piece of code costs, or for a single script that has no build step.