JavaScript Minifier
Minify JavaScript snippets with Terser and check syntax errors before copying output.
JavaScript Minifier
Minify JavaScript snippets with Terser to remove whitespace, shorten local names, and reduce code size for examples, embeds, and small scripts.
Minifier options
- Compression removes unreachable code and simplifies expressions
- Name mangling shortens local variable and function names
- Syntax errors are reported before output is generated
How to use JavaScript Minifier
The JavaScript minifier uses Terser to compress snippets, remove whitespace, and optionally shorten local names for compact examples and embeds.
Developers often use this page when they need javascript minifier, js minifier, minify javascript, and terser online.
Privacy and data handling
This tool is designed to run in your browser for normal use, so your input does not need to be sent to a server.
- Input and output stay on the page while you work.
- Copy buttons use your browser clipboard permission when available.
- Avoid pasting private production data on shared or untrusted devices.
Examples
Minify a small function
Input
function add(a, b) { return a + b; }Output
function add(n,d){return n+d}Terser removes whitespace and can shorten local names.
Steps
- 1Paste JavaScript into the input.
- 2Review the generated minified output.
- 3Copy the output after checking for syntax errors.
Common use cases
- Minify small embed scripts.
- Shrink JavaScript examples for docs.
- Catch syntax errors before copying a snippet.
Practical tips
- Minification is not obfuscation or security.
- Test minified output when code depends on function or class names.
- Keep source code readable and only ship minified copies when needed.
FAQ
Does minifying JavaScript change behavior?
It should not for normal code, but aggressive compression can expose assumptions. Test important snippets after minifying.
What is name mangling?
Mangling shortens local variable and function names to reduce output size.