Shrink your JavaScript by removing comments and collapsing whitespace β safely protecting your strings, template literals and regular expressions. Paste your code, choose your options and copy the smaller result. 100% in your browser β nothing is uploaded or stored.
π Everything runs in your browser. Your input is never uploaded, logged or stored.
The JavaScript Minifier shrinks your scripts by removing comments and collapsing whitespace, while carefully protecting your strings, template literals and regular expressions so the code keeps working exactly as before. Smaller scripts download and parse faster, which helps page speed and Core Web Vitals β factors that affect both the visitor experience and search performance.
It is part of the Performance & Code Tools group in our free SEO Toolkit, alongside the HTML Minifier and CSS Minifier. To make minified code readable again, use the Code Beautifier, and estimate total page weight with the Page Size Calculator, and embed images inline with the Base64 Image Encoder. This is a safe, conservative minifier β it does not rename variables β so for aggressive optimisation a build-step tool is the right choice. Everything runs in your browser β your input is never uploaded or stored.
Minify JavaScript without breaking your logic.
Removes line and block comments that the engine ignores.
Trims indentation and extra spaces between statements.
Protects strings, template literals and regular expressions.
See the byte size before and after, with the percentage saved.
Paste, choose options, copy the smaller file.
Drop in a function, a module or a whole file.
Choose what to remove.
Compare original and minified sizes.
Use the minified script on your site.
Comments and indentation gone; logic untouched.
// add two numbers function add(a, b) { return a + b; }
function add(a, b) { return a + b; }
JavaScript minification reduces the size of a script by removing characters that are not needed to run it β comments, indentation, line breaks and surplus spaces. The behaviour is unchanged, but the file is smaller, so it downloads and parses faster. This tool performs safe, conservative minification: it strips comments and collapses whitespace while protecting the parts of your code where spacing matters. It is part of the Performance & Code Tools group.
There are two levels of JavaScript minification. Conservative minification, which this tool does, removes comments and whitespace without changing any names or structure, so it is safe to apply to any valid script. Aggressive minification, performed by build tools such as Terser, also renames variables, drops dead code and rewrites expressions for maximum savings. Aggressive tools squeeze out more bytes but need a build step and careful testing; this tool gives you quick, reliable gains with zero risk to your logic.
| Protected | Why |
|---|---|
| Strings | Spaces inside quotes are part of your data |
| Template literals | Backtick strings keep their exact formatting |
| Regular expressions | Spaces and slashes inside a regex are significant |
| Division operators | A slash used for division is never mistaken for a regex |
Smaller scripts download and start running sooner.
Lighter scripts help your Core Web Vitals scores.
Fewer bytes served reduces data and hosting costs.
Speed gains matter most on slower connections.
This tool is designed to be safe. It only removes comments and whitespace outside of strings, template literals and regular expressions, and it does not rename anything. For ordinary, valid JavaScript the behaviour is unchanged. As with any change to production code, test the minified output before deploying.
No, and that is deliberate. Renaming variables and rewriting code can produce much smaller files but requires a full parser and careful testing. This tool focuses on safe comment and whitespace removal so you get quick gains with no risk. For maximum compression, use a build-step tool such as Terser in your pipeline.
The tool scans your code character by character and tracks the previous meaningful token. A slash that follows a value or closing bracket is treated as division, while a slash in a position where an expression begins is treated as the start of a regular expression. This avoids the classic mistakes that naive minifiers make.
No. Minification runs locally in your browser with JavaScript. Nothing you paste is uploaded, logged or stored, so the tool is safe for proprietary scripts, unreleased features and confidential client work.
Trim script weight to improve load times.
Compress small scripts and inline code blocks.
Compact JavaScript shipped with widgets.
See how comments and whitespace add to file size.
Use the JavaScript Minifier with these tools from the SEO Toolkit: compress markup with the HTML Minifier, shrink stylesheets with the CSS Minifier, reformat minified code with the Code Beautifier, estimate weight with the Page Size Calculator, embed images inline with the Base64 Image Encoder, and build head tags with the Meta Tag Generator.
Anyone who wants lighter, faster scripts.
Everything about minifying JavaScript.
It reduces the size of your script by removing comments and collapsing whitespace, while protecting strings, template literals and regular expressions so the behaviour is unchanged. You paste your code, pick your options and copy the smaller, minified output for use on your site.
Yes, completely. There is no cost, no sign-up and no limit on how much code you minify. The tool runs entirely in your browser, so there are no server costs and nothing to pay for.
It is designed not to. The tool removes only comments and whitespace outside of strings, template literals and regular expressions, and it never renames anything, so valid scripts behave the same. As with any production change, test the output before you deploy it.
No, and that is intentional. Variable renaming and code rewriting need a full parser and careful testing. This tool focuses on safe comment and whitespace removal so you get quick gains with no risk. For maximum compression, use a build-step tool such as Terser.
Yes. Minification happens locally in your browser with JavaScript. Nothing you paste is uploaded, logged or stored, which makes the tool safe for proprietary scripts, unreleased features and confidential client work.
The tool scans your code character by character, identifying strings, template literals and regular expressions, and leaves their contents untouched. Only the code outside these literals has its whitespace collapsed, so a space inside a string or a regex is always preserved.
It tracks the previous meaningful token. A slash after a value, variable or closing bracket is treated as division, while a slash where an expression can start is treated as the beginning of a regular expression. This avoids the errors naive minifiers often make.
It depends on how many comments and how much indentation your code contains. Heavily commented, nicely formatted code can shrink noticeably, while compact code saves less. Because this tool does not rename variables, savings are smaller than an aggressive build tool but completely safe.
Minification removes comments and formatting, so it is not perfectly reversible, but you can reformat minified code into a clean, indented layout with the Code Beautifier. Always keep your original source in version control as the source of truth.
This tool is ideal for one-off files, snippets and learning. For a live site, minify automatically in your build process or via an optimisation plugin so every change is processed consistently. Use this tool for ad hoc scripts and to see the savings.
Yes. The minifier is fully responsive, so you can compress JavaScript from a phone or tablet. Pasting your code, toggling options, viewing the savings and copying the output all work the same as on desktop.
Convert, compress, and resize images in multiple formats β JPG, PNG, WebP, ICO, and more.
Calculate in-hand salary, CTC breakup, tax deductions, and more for Indian employees.
Convert length, weight, temperature, speed, volume, and 200+ measurement units instantly.
Count words, convert case, generate lorem ipsum, find & replace text, and more writing utilities.
Strip comments and whitespace safely to make your scripts lighter and your pages faster in seconds β free, private and instant in your browser.
β‘ Open the Minifier β All Performance Tools