HTML / CSS / JS Minifier & Beautifier
Minify or beautify HTML, CSS and JavaScript and see how many bytes you save.
Whitespace inside <pre>, <textarea>, <script> and strings is never changed.
About this tool
Minifying removes everything a browser does not need: comments, indentation, line breaks and, for JavaScript, long variable names. The page behaves the same but downloads and parses faster, which helps Core Web Vitals on slow mobile connections. Beautifying does the opposite and turns a one-line bundle or a messy stylesheet back into readable, indented code.
This tool handles HTML, CSS and JavaScript in one place. JavaScript goes through Terser, the same minifier used by Vite, webpack and Rollup. HTML and CSS use careful rules that keep whatever changes how a page looks: whitespace inside <pre> and <textarea>, single spaces between inline elements, and spaces in selectors like .card :hover. You see the original size, the result and both gzip sizes, and the code never leaves your browser.
How to use HTML / CSS / JS Minifier & Beautifier
- Pick HTML, CSS or JavaScript, or simply paste code: the language is detected automatically.
- Choose Minify or Beautify and set the options, such as removing comments or shortening variable names.
- Check the savings in the status bar and the size cards, including the gzip size your server actually sends.
- Copy the result or download it as a .min file.
Examples
CSS
.btn { color : red ; margin: 0 auto; } .btn{color:red;margin:0 auto} JavaScript with Terser
function add(first, second) {
return first + second;
} function add(n,d){return n+d} Parameter names are shortened; top-level names stay so other scripts can still call add().
HTML
<p>Hello <b>world</b> !</p> <!-- note -->
<p>Hello <b>world</b> !</p>
What is removed and what is kept
- Comments are removed, except /*! … */ licence comments in CSS and IE conditional comments in HTML. In JavaScript you can choose to keep licence comments.
- Runs of spaces and line breaks in HTML text become one space. A space is removed entirely only next to block elements such as <div> or <p>, so "Hello <b>world</b>" never turns into "Helloworld".
- Content of <pre>, <textarea>, <script> and string literals is never touched.
- In CSS, spaces around { } ; , > and ~ are removed and the last semicolon in a block is dropped, but the descendant space in .card :hover and the spaces around + and - in calc() are kept, because removing them changes the meaning.
- Terser also rewrites JavaScript: it shortens local names, removes unreachable code and folds constants. It never renames global variables or object properties.
Minify and compress: you need both
Gzip and Brotli compression on the server already shrink text a lot, so the real gain of minifying is smaller than the raw numbers suggest. That is why the tool shows gzip sizes too: a stylesheet that goes from 40 KB to 30 KB might go from 9 KB to 7 KB over the wire.
Both still matter. Minified code compresses slightly better, and the browser has to parse the uncompressed size, which counts on low-end phones. In a project with a build step, let the bundler minify; use this tool for snippets, inline scripts, email templates, CMS fields and quick checks.
Frequently asked questions
Everything you need to know about this tool and data security.
Can minifying break my JavaScript?
Terser is used in production by most JavaScript build tools and is safe for valid code. Problems usually come from code that relies on function names, such as reading fn.name; turn off "Shorten variable names" in that case. If the code has a syntax error, the tool shows the message and position instead of producing output.
Can I un-minify a minified file?
Beautify restores indentation and line breaks, which makes a bundle readable again. Original variable names and comments cannot be recovered; for that you need the source map that was created with the bundle.
Does it create source maps?
No. Source maps are useful for code you deploy and debug, which a build tool such as Vite or esbuild handles. This tool is meant for quick, standalone snippets.
Is my code sent to a server?
No. HTML and CSS are processed by code on this page, and Terser is downloaded to your browser the first time you choose JavaScript. Nothing you paste is uploaded or stored.
Is my data safe when using this tool?
Yes, 100% safe. This tool operates entirely inside your web browser using client-side JavaScript and WebAssembly. Your data never touches any external server.
Related Tools
Generate SEO meta tags, Open Graph and Twitter card tags for your page, with length checks and a social preview.
Shrink SVG files by removing editor data, comments and excess precision, with a before-and-after preview.
Prettify, validate, and minify JSON data instantly in your browser.
Featured Projects tech-fun.net
Explore more AI & productivity tools
Nihongo GameBox
Master Japanese typing, Kana, and JLPT N5–N1 vocabulary through interactive retro arcade games.
ResumeGPT
Tailors CVs and cover letters to every job opportunity with a multi-agent LLM pipeline, job tracking, and scheduled discovery.
CollectMind
Turns your bookmarks into a searchable AI knowledge base — entirely on-device, powered by Chrome's built-in Gemini Nano.