HTML / CSS / JS Minifier
Paste source code, pick HTML / CSS / JS, and the tool removes redundant whitespace and (optionally) comments, returning a single-line minified version with the byte size before and after plus the percentage saved. Pure regex-based — fast, fully offline, no library required. Best for small inline snippets and final-mile size trims; for build pipelines, use a dedicated minifier like terser or esbuild.
<!doctype html><html lang="en"><head><title>Sample Page</title></head><body><h1>Hello, world!</h1><p> This is a paragraph with multiple lines. </p></body></html>
How to use
- Paste your source code.
- Pick the language (HTML / CSS / JS).
- Toggle whether to strip comments.
- Copy the minified output.
Frequently asked questions
- Is this safe for production?
- For small CSS or HTML, yes — the rules are conservative. For JavaScript, prefer a tool like terser or esbuild in your build, since this tool doesn't rename variables, fold constants, or do dead-code elimination.
- Why isn't my JS more compressed?
- True JS compression needs an AST-based tool. This minifier removes whitespace and comments only — that's already a big win for hand-written snippets but won't match terser's output.
- Will it break HTML inside <pre> or <textarea>?
- It can — whitespace there is significant. Avoid running the minifier on HTML containing those elements, or replace their contents with a placeholder first.
- Are CSS comments important?
- Sometimes — license headers in /*! comments by convention are kept by professional minifiers. This tool removes all comments if 'strip comments' is on; for license-preserving output, set it off.
Related tools
SVG Optimizer
Shrink an SVG with SVGO — strip editor cruft, round coordinates, merge shapes — and see before and after side by side. Nothing is uploaded.
Image Compressor
Compress and resize JPEG, PNG, and WebP images in your browser.
PDF Compressor
Shrink a PDF by re-encoding the images inside it. Text stays selectable and searchable. Nothing is uploaded.
CSS to JS Style Object Converter
Convert a CSS declaration block into a React/JS inline style object, in your browser.
CSS Selector Tester
Test a CSS selector against your HTML and see exactly which elements it matches, in your browser.
XML Formatter & Minifier
Beautify XML with clean indentation or minify it to one line, in your browser.