JavaScript Minifier Online
Minify and compress JavaScript by removing comments and whitespace, then see exactly how many bytes you saved. Free, private and runs entirely in your browser. Speed up your site and improve your PageSpeed score.
- Remove comments
- Collapse whitespace
- Live size report
- Copy & download
Last updated:
- Runs in your browser
- No upload
- No sign-up
- 100% Private
- Live size report
- Works on mobile
What is the ToolDeck JavaScript Minifier?
ToolDeck JS Minifier is a free online JavaScript minifier that works inside your web browser. It removes comments, whitespace and line breaks from your JS to reduce file size, shows the bytes saved and a Gzip estimate, and lets you copy or download the minified .js file. Your code is processed on your own device, so nothing is uploaded and no account is needed.
- Price
- Free, no premium tier
- Account required
- No
- Code uploaded to a server
- No, minification runs locally in your browser
- What it removes
- Comments, extra whitespace, tabs and line breaks
- What it does not do
- Rename variables, remove console.log, tree-shake, obfuscate or generate source maps
- Output
- Minified JavaScript with size report and Gzip estimate
- Export options
- Copy to clipboard or download as .js
- Works on
- Chrome, Edge, Firefox, Safari, iOS and Android browsers
How to minify JavaScript online in 3 steps
- 1
Paste your JS
Paste your raw, unminified JS code into the left text box. The tool works entirely in your browser.
- 2
Choose options
Toggle options like removing comments or collapsing whitespace to get the exact output you need.
- 3
Copy or Download
Click Copy to grab the minified JS, or download it directly as a .js file for production.
JavaScript minification example: before and after
The minifier removes comments, indentation and line breaks. The code behaves exactly the same, but the file is smaller.
Before (readable JS)
// Add two numbers
function addNumbers(a, b) {
/* return the sum */
return a + b;
}
console.log(addNumbers(2, 3));After (minified JS)
function addNumbers(a,b){return a+b}console.log(addNumbers(2,3));JavaScript minification best practices
Follow these six habits to get faster pages without breaking your code.
- 1
Keep your original source
Always store the unminified file in version control. Minified code is only meant for production.
- 2
Minify as the last step
Minify after you have finished editing and bundling, so you do not have to edit unreadable code.
- 3
Serve with Gzip or Brotli
Enable compression on your server or CDN. Minification and compression work together, and the Gzip estimate here shows the combined effect.
- 4
Test the minified file
Load the minified file in a staging page and check the browser console for errors before you deploy.
- 5
Use a build tool for large apps
For big projects, let Vite, Webpack or esbuild minify during the build. Use this tool for quick files, snippets and checks.
- 6
Cache with versioned file names
Add a version or hash to the file name, for example app.min.js?v=2, so visitors get the new file after you update it.
JavaScript minifier FAQ: questions people ask
Quick answers about minifying JS, PageSpeed, Gzip, Terser, privacy and safety.
What is JavaScript minification?
JavaScript minification is the process of removing unnecessary characters from your source code without changing its functionality. This includes removing whitespace, comments, and line breaks, which significantly reduces the file size.
How do I minify JavaScript online for free?
Paste your JavaScript into the ToolDeck JS Minifier above, choose whether to remove comments and collapse whitespace, then click Minify. Copy the result or download it as a .js file. It is free, needs no account and nothing is uploaded.
Why should I minify my JS files?
Large JavaScript files take longer to download, parse and execute, which can slow interaction and hurt the user experience. Minifying your JS reduces its size, allowing the browser to download and run it faster.
Does minifying JavaScript improve SEO and PageSpeed?
Minification reduces the amount of JavaScript the browser must download, which can improve load time and Lighthouse or PageSpeed Insights results. Page speed is one of many signals, so minifying helps performance but does not guarantee a ranking change.
How do I fix the Lighthouse "Minify JavaScript" warning?
Lighthouse flags JavaScript files that still contain comments and whitespace that could be removed. Minify the flagged file, upload the minified version, and run the audit again. This tool removes comments and whitespace, which is what that audit checks.
How much smaller will my JavaScript file get?
It depends on how many comments and how much indentation your code has. Heavily commented, well-indented code shrinks the most. The live size report shows the exact bytes and percentage saved for your file, plus a Gzip estimate.
Is this JS minifier safe and private?
Yes. Unlike tools that upload your code to a server, this JS minifier runs entirely in your browser using JavaScript. Your proprietary code never leaves your device. You can check the browser network tab to confirm.
Will minifying break my JavaScript code?
A basic minifier only removes spaces and comments, which does not break working code. Advanced minifiers like Terser can rename variables and sometimes break code that relies on specific names. This tool focuses on safe whitespace and comment removal.
What is the difference between this tool and Terser or UglifyJS?
Terser and UglifyJS parse your code and can rename variables, drop dead code and apply deeper compression, which gives smaller files but needs a build step. This tool is a quick, safe, no-install option that removes comments and whitespace only. For production bundles, use it alongside or instead of a build tool depending on your needs.
Minification vs Gzip vs Brotli: what is the difference?
Minification changes the file itself by removing characters. Gzip and Brotli compress the file while it travels from your server to the browser. They work together, so use both. Brotli often gives smaller files than Gzip on modern browsers.
Does this tool create a source map?
No. This tool removes comments and whitespace and does not generate source maps. If you need source maps for debugging, use a build tool such as Vite, Webpack or esbuild with source map output enabled.
Does this tool remove console.log statements?
No, this tool only removes spaces and comments. To remove console.log calls, use a build tool like Webpack or Vite with the Terser plugin and its drop_console option.
Can I minify multiple JS files at once?
You can paste multiple files into the box, but for best results, concatenate them into one file first and then minify the combined file.
Is minification the same as obfuscation?
No. Minification reduces file size. Obfuscation deliberately makes code hard for humans to read to prevent reverse engineering. This tool does not obfuscate code.
What is the difference between minified and unminified code?
Unminified code is readable for developers, with spaces, indentation and comments. Minified code is compact text with that extra formatting removed, so the browser has fewer bytes to download.
Can I reverse minified JavaScript back to readable code?
You can format it again with a beautifier, which restores indentation and line breaks. Removed comments cannot be recovered, so always keep your original source file.
Can I minify JS on my phone?
Yes, this browser-based tool works on Safari for iOS and Chrome for Android.
Do I need to keep the original JS file?
Always. Never overwrite your original source code. Keep the unminified version in your repository for future editing, and only use the minified version on your live production server.
Does it support ES6+ and modern JavaScript?
Yes, it leaves all modern JavaScript syntax such as arrow functions, classes, template literals and modules intact. It only removes whitespace and comments.
Can it minify TypeScript?
No. TypeScript must be compiled to JavaScript first. Once it is plain JS, you can paste it here.
How do I minify JavaScript for WordPress?
Paste your custom theme or plugin JS here, download the minified file, and upload it to your theme folder or enqueue it in place of the original. Keep the unminified copy for future edits.
What about Gzip?
Minification and Gzip work together. Minification removes characters; Gzip compresses the resulting file for transit. This tool estimates the Gzip size for you.
Is there a file size limit?
There is no hard limit. The tool uses your browser memory, so it can handle very large files, though very large files may take a moment to process.
Is this tool free?
Yes, completely free. There are no limits, no sign-ups, and no premium tiers.
JavaScript minification glossary
Short definitions of the terms you will meet when optimizing JavaScript for speed.
- Minification
- Removing characters that are not needed to run the code, such as comments, spaces and line breaks, without changing what the code does.
- Gzip
- A compression format that web servers use to shrink files while they travel over the network. The browser unpacks the file on arrival.
- Brotli
- A newer compression format supported by modern browsers over HTTPS. It often produces smaller files than Gzip.
- Obfuscation
- Deliberately making code hard for humans to read, usually to discourage reverse engineering. It is different from minification.
- Tree shaking
- A build step that removes exported code your app never uses. It needs a bundler and is not done by whitespace minifiers.
- Source map
- A file that maps minified code back to your original source so browser dev tools can show readable code while debugging.
- Bundling
- Combining many JavaScript files into one or a few files so the browser makes fewer requests.
Everything you get for free
One-click Minification
Instantly remove all unnecessary whitespace, line breaks, and comments from your JS file with a single click.
Live Size Report
See exactly how many bytes you saved and what percentage of the original file size was reduced.
Gzip Estimate
Get an estimate of what your file size will be after Gzip compression, which is what most servers use.
Remove Comments
Strip out all // and /* ... */ comments. Perfect for production environments where code readability does not matter.
Collapse Whitespace
Remove every unnecessary space, tab, and newline character, reducing your JS to its absolute minimum size.
Copy to Clipboard
Instantly copy the minified JS to your clipboard for easy pasting into your code editor or build pipeline.
Download as .js
Download your minified code directly as a .js file, ready to upload to your web server.
Privacy First
All processing happens locally. Your proprietary code never leaves your computer, making it 100% safe.
What people use it for
Web Developers
Quickly minify JS before pushing to production. Reduce page weight and improve loading times for your users.
WordPress Users
Minify custom JS added to your theme or child theme to ensure your site loads as fast as possible.
E-commerce Stores
Every kilobyte counts for conversion rates. Minify your store JS to keep bounce rates low and sales high.
PageSpeed Optimization
Improve your Google Lighthouse scores by reducing the time it takes for the browser to download and parse JS.
React & Vue Builds
Before running a full Webpack or Vite build, quickly test how small your JS can get with basic minification.
Learning & Teaching
Show students the difference between readable, commented JS and the compressed code that actually ships to browsers.
ToolDeck vs build tools and other online JS minifiers
Many online minifiers upload your code to a server. This one runs locally in your browser. Build tools like Terser go further with variable renaming, but need installation and configuration.
| Feature | TToolDeck | Build tools (Terser, esbuild) | Typical online tools |
|---|---|---|---|
| Runs entirely in your browser | Yes | No | No |
| Code never sent to a server | Yes | Yes | No |
| No sign-up or account | Yes | Yes | No |
| Removes comments and whitespace | Yes | Yes | Yes |
| Live size report | Yes | Partial | No |
| Gzip estimate included | Yes | No | No |
| Free without limits | Yes | Yes | Partial |
| No installation required | Yes | No | Yes |
| Copy & download output | Yes | Yes | Partial |
| Renames variables / tree-shaking | No | Yes | Partial |
Speed up the rest of your page
JavaScript is only one part of page weight. Minify your CSS and HTML and compress your images to get the full benefit.
CSS Minifier
Compress your stylesheets the same way, with a live size report and Gzip estimate.
HTML Minifier
Minify HTML, including inline CSS and JavaScript, to cut page weight.
Image Compressor
Images are often the heaviest part of a page. Shrink them in your browser too.
JSON Formatter
Format, validate or minify JSON used by your scripts and APIs.
Related developer tools
Free developer tools that run in your browser. Nothing uploaded, ever.
JS Minifier
You are hereMinify JavaScript to reduce file size.
CSS Minifier
Compress CSS code to improve performance.
HTML Minifier
Minify HTML, inline CSS and JS.
JSON Formatter
Format, validate and minify JSON.
SQL Formatter
Format and beautify SQL queries.
SVG Cleaner
Clean up messy SVG code.
Codebase Tokenizer
Count LLM tokens in your codebase.
Regex Tester
Test and debug regular expressions.
Your code never leaves your device
There is no upload step and no server-side handling. The JS is read from your device, minified inside your browser tab, and saved back to your device. Nothing about the file, its name or its contents reaches any server. Open the browser network tab while using the tool and confirm there are no outbound requests carrying your code.