Skip to main content

Code Minifier

Shrink your code so pages load faster, and see exactly how much you saved.

Minified code
Your result will appear here

Minified entirely in your browser — your code is never uploaded.

About this tool

The code minifier shrinks JavaScript, CSS, HTML, JSON, XML and SQL so pages load faster, and tells you exactly how many bytes and what percentage you saved.

What separates it from a whitespace stripper is that JavaScript goes through terser — the same minifier production build pipelines use. It renames local variables and removes unreachable code, so the result is meaningfully smaller than simply deleting spaces.

For HTML it is deliberately conservative: the contents of <pre>, <textarea>, <script> and <style> are left byte-for-byte, because whitespace in those elements is significant and collapsing it changes what the page renders or runs.

Sizes are reported in UTF-8 bytes, not characters, because a Thai character occupies three bytes — counting characters would show a number that does not match the file your visitors actually download. Everything runs in your browser; your code is never uploaded.

How to use

  1. 1Paste the code you want to shrink into the input box
  2. 2The language is detected automatically, or pick it from the list
  3. 3See the before and after size and the percentage saved
  4. 4Copy or download the minified file

Frequently asked questions

What does minifying JavaScript actually do?
More than removing whitespace: local variables are renamed to short names and unreachable code is dropped, which shrinks files far more than whitespace removal alone. Test the output before shipping it.
Will minifying break my site?
It uses the same minifier production build tools use, so it is safe for most code. Code that relies on function or class names at runtime can be affected, so always test.
Why is the content of pre and script left alone in HTML mode?
Whitespace inside those elements is significant. Collapsing it inside <pre> changes what visitors see, and inside <script> it can change what the code does — so both are left byte-for-byte.
What unit are the sizes in?
UTF-8 bytes, not characters. A Thai character takes three bytes, so counting characters would report a number that does not match the real file size.
Should I always minify before uploading?
If you already use a build tool it usually minifies for you. This tool is for standalone files you upload directly — a small inline script, or a theme file you are editing by hand.

Related tools

Code Beautifier

Re-indent HTML, CSS, JavaScript and SQL so it reads cleanly.

JSON Formatter

Format, validate and minify JSON — for developers.

Image Compressor

Shrink JPG & PNG without losing quality — runs in your browser.

SQL Formatter

Turn a long SQL statement into something readable.