Calculates on this device. File exports run online.
Code Minifier
Paste code or open a file, and the page makes it smaller by removing comments, line breaks and spaces it does not need. It can also do the reverse and lay minified code out so you can read it. Everything happens in your browser.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose the button below them.
Your result
How it was worked out
How to minify code
- Paste your code into the box, or press Or open a code file from your device.
- Leave Language on Find out from the code, or choose JavaScript, CSS, HTML, JSON, XML or SVG, or SQL.
- Press Minify. The minified code is shown with its size before and after.
- Press Copy or Download to use the result.
- To read minified code, choose Beautify and press Beautify.
What is removed, and what is kept
- JavaScript: comments and spaces. Strings, template literals and regular expressions are copied as they are. A line break stays where removing it could change the meaning (automatic semicolon insertion), and a + + or - - stays apart. Comments that start with /*! (licences) are kept unless you untick that.
- CSS: comments and spaces, the last ; of each rule and the space before !important. A space that is part of a selector, as in a :hover, is kept.
- HTML: comments and the spaces the browser would not show. One space stays between inline elements such as <b> and <i>. The content of <pre> and <textarea> is not changed; CSS and JavaScript inside <style> and <script> are minified too.
- JSON: every space outside strings. Numbers are copied exactly as written, so 2.50 stays 2.50.
- XML and SVG: comments and the spaces between elements. Elements that hold text, and anything under xml:space="preserve", keep their spaces.
- SQL: comments (-- and /* */) and spaces. Quoted text and $$ function bodies stay as they are. In MySQL # also starts a comment: tick it under More options.
Worked example
A JavaScript function add(a, b) written on four lines with a comment line, 64 bytes in all, becomes function add(a,b){return a+b;}: 30 bytes, 53.1% smaller. Beautify lays it out again on three lines; the comment is gone for good.
Limits you should know
- Names of variables and functions are not shortened, and code is not rearranged. A bundler such as esbuild or terser does that with your whole program in view; the result here is larger, but always means the same.
- The page reads the language with small rules, not a full parser: code with a syntax error is minified as far as it can be read, and a text that is not closed (a string, a comment) is reported with its line and column.
- JSX, TypeScript, PHP, Java and SCSS are not supported.
- Find out from the code looks at how the code starts. When it guesses wrong, choose the language.
Privacy
Minify and Beautify work in your browser; your code is not uploaded. Only when you use the box below is the code in the box sent to the Toolvito server to minify it there or to check and convert SQL. Download the result within one hour after the job finishes. Choose Delete files now to request earlier removal. The hourly cleanup normally removes files within one to two hours after completion.