JavaScript Minifier
Shrink JavaScript by removing whitespace and comments and shortening local names, with a size saved readout.
Minified live as you type. Code never leaves your browser.
Shrinks code by removing whitespace and comments and shortening local names, all in your browser.
How to minify JavaScript online
Paste your JavaScript
Drop a script or a fragment into the input and the minified version appears immediately below.
Check the savings
The size before and after and the percentage saved are shown, so you can see what the smaller file is worth.
Copy the result
Use Copy JavaScript to grab the minified script and paste it wherever you need it.
Why use this tool
Removes whitespace and comments
Strips indentation, line breaks, and comments, then collapses the script so only the code the runtime needs is left.
Shortens local names
Renames local variables and function arguments to short forms where it is safe, squeezing out extra bytes beyond whitespace alone.
Size saved readout
Shows the size before and after minifying plus the percentage saved, so you can measure exactly what the smaller file is worth.
Clear syntax errors
A missing bracket or a stray token is reported with the reason instead of producing broken output, so you can fix the source and try again.
Handles modern syntax
Template literals, regular expressions, and current language features are preserved so the minified script behaves the same as the original.
Runs entirely in your browser
Everything happens on your device. Your script and its logic are never uploaded.
About this tool
This JavaScript minifier shrinks a script by removing the parts that only exist for humans: indentation, line breaks, and comments. It then goes a step further and shortens local variable and argument names to short forms where that is safe, which squeezes out bytes that stripping whitespace alone cannot. Paste a script and the smaller version appears instantly, with the size before and after and the percentage saved shown next to it, so shrinking a snippet is paste, glance at the savings, copy.
The result behaves the same as the input. Template literals, regular expressions, and modern language features are preserved exactly, and only local names are shortened, so nothing your code exposes to the outside is renamed. If the script has a syntax error, a missing bracket or a stray token, the reason is reported instead of broken output, so you can fix the source and run it again rather than shipping something that will not parse.
Everything runs in your browser, so proprietary scripts and unreleased code never leave your device. For other formats, the CSS minifier does the same job for stylesheets and the HTML minifier for markup, while the JSON minifier strips whitespace from data files. Minifying is a quick way to see what your whitespace and comments cost and to hand off a smaller file when a full build step is more than you need.
Frequently asked questions
- What does minifying actually remove?
- Indentation, line breaks, and comments, plus the whitespace between tokens. It also shortens local variable and argument names where that is safe. The logic of your script is unchanged, so the minified output runs the same as the original, just smaller.
- Will minifying break my JavaScript?
- No. Template literals, regular expressions, and modern syntax are preserved, and only local names are shortened, never anything your code exposes externally. The output is functionally the same as the input.
- What happens if my code has a syntax error?
- The tool reports the reason for the error instead of producing broken output, so you can find and fix the problem in the source and minify again. It will not hand you a file that fails to parse.
- Is my code uploaded anywhere?
- No. Everything runs in your browser and the script never leaves your device, which matters when the code belongs to a client project or an unreleased product.
- Is there a limit on file size?
- No fixed limit. Processing happens in your browser tab, so large scripts are bounded by your device memory rather than an upload cap, and the output area scrolls instead of stretching the page.
Related tools
CSS Minifier
Strip comments and whitespace from CSS to shrink it, or beautify a minified stylesheet back into readable rules, with a size saved readout.
HTML Minifier
Shrink HTML by removing comments and collapsing whitespace, while leaving preformatted text, inline scripts, and inline styles untouched. See the size saved.
JSON Minifier
Minify JSON to the smallest single line, with original vs minified byte size and the percentage saved.
API Key Generator
Generate cryptographically random API keys and tokens in hex, base62, or base64url, with control over length, an optional prefix, and bulk output.
ASCII Table Reference
The full ASCII character set with decimal, hex, octal, binary, and HTML codes. Search by code, character, or name.
Atbash Cipher
Mirror the alphabet so A swaps with Z, B with Y, and so on. Atbash is its own inverse, so one field both encodes and decodes as you type.