HTML, CSS and JavaScript minifier
Paste code and get a smaller file. Ctrl+C copies the result.
Private: your files never leave this deviceNothing is uploaded or stored on a serverWorks right here in your browserMinify removes spaces, line breaks and comments the browser does not need.
How to minify HTML, CSS and JavaScript
Paste or open
Paste HTML, CSS or JavaScript, open a file or drop it on the Input pane. The language is picked for you; change it with the tabs if needed.
Choose options
Minify makes it small; Beautify makes it readable. For JavaScript you can shorten names and remove console logging. HTML can also minify its inline styles and scripts.
Copy or download
See the size before and after, also after gzip. Press Copy, Ctrl+C with nothing selected, or Download to save a .min file.
Good to know
- JavaScript is minified by terser: it removes spaces and comments, shortens names that only your code uses, and simplifies code such as if statements, without changing what it does.
- CSS is read piece by piece: text in quotes, url() addresses and custom properties (--name) stay exactly as written, and calc() keeps its spaces and units. Colours like #ffffff become #fff and 0px becomes 0.
- HTML keeps the spacing between words and inside <pre> and <textarea>. Inline <style> and <script> blocks are minified with the same tools; a block with a mistake is left as it was and you are told which line.
- Files over 2 MB stay out of the editor and are read by the worker, so large bundles minify without freezing the page.
- Errors show the line and column. Go to error selects the spot in the input.
Questions people ask
Is the minified code safe to use in place of the original?
Yes, it does the same thing. JavaScript is minified by a well-tested minifier that understands the code, not by search and replace. CSS is read token by token, so text in quotes, url() addresses and calc() sums are kept exactly. Test the page once after minifying, as you would after any build step.
What do the gzip numbers mean?
Most web servers compress files with gzip before sending them. The gzip size is close to what visitors really download, so it is the fairest way to compare before and after.
What does Shorten names do?
It renames variables and function arguments that are only used inside your code to one or two letters. Names other scripts can see, such as global functions, are left alone.
Why are some comments kept?
Comments that start with /*! or mention @license usually carry a licence that must stay with the code. Untick Keep licence comments to remove them too.
Can I turn minified code back into readable code?
Yes. Choose Beautify to format it with line breaks and indent. Shortened names cannot be brought back, but the structure becomes easy to read.
Is my code uploaded?
No. Everything runs in a background worker in your browser. Nothing is sent to a server.