HTML, CSS & JS Minifier, Beautifier & Linter

Minify, beautify or lint HTML, CSS and JavaScript. Code is tokenised first, so strings, regexes, calc() and <pre> blocks survive; the CSS linter reports duplicate properties, invalid units and shorthand chances by line.

Formatter Web & Dev Updated Oct 3, 2026
Learn how this works
How to Use
  1. Pick the language — HTML, CSS or JavaScript — and the action: Minify, Beautify or Lint.
  2. Paste your code into the input box. The result updates as you type.
  3. For Beautify, choose 2 spaces, 4 spaces or tabs. For Minify, tick Keep licence comments to keep /*! … */ and @license blocks.
  4. Read the size bars and readouts: bytes before and after, the change, and the gzipped size. In Lint mode they count errors, warnings and info notes, and the report lists each one with its line number.
  5. Press Copy result or Download, or Use as input to send the result back through the other way.
Input
CSS
Presets
Minified
Sizes appear here.
Input
—
Output
—
Change
—
Gzipped
—

Worked Example

Minify a script. The “Minify a script” preset is a 10-line function of 318 bytes. Its three comments are 23 + 28 + 33 = 84 bytes, the two semicolons right before a } are 2 more, and spaces, indentation and line breaks are 62. Removing them leaves 170 bytes: (318 − 170) ÷ 318 = 46.5% smaller. The string "https://example.com/api" comes through unchanged, and one line break stays after the loop’s closing brace, where a missing semicolon might matter. Gzipped (level 6), the file goes from 224 to 156 bytes; a browser’s own gzip can differ by a byte or two.

Minify CSS that is already tight. The CSS button sample is also 318 bytes, but it has only one comment (16 bytes), four optional semicolons before } (4 bytes) and four line breaks (4 bytes). It minifies to 294 bytes, only 7.5% smaller. Beautified instead, the same CSS is 390 bytes on 26 lines, with one declaration per line.

The common mistake: removing every space around + and −. A naive minifier turns width: calc(100% + 2rem) into width:calc(100%+2rem), which browsers reject as invalid, so the whole declaration is dropped. Inside calc() the + and − must have a space on each side. This minifier only tightens +, > and ~ between selectors, so the output is .box{width:calc(100% + 2rem)}. The JavaScript version of the same mistake is stripping everything after //, which cuts "https://example.com" in half.

Show Work

Paste code above to see what was removed, added or flagged.

Formulas and Lint Rules

Saving
% = (before − after) ÷ before × 100
Bytes counted as UTF-8, so “é” is 2 bytes
What minify removes
before = after + comments + semicolons + whitespace
HTML also counts the bytes saved inside <style> and <script>
Gzip
DEFLATE = LZ77 + Huffman
Repeats become back-references; the size is measured in your browser
Safe spacing
a + +b, a - -b, calc(x + y)
Spaces that must stay, or the code means something else

CSS lint rules

  • Duplicate property (warning) — the same property twice in one rule, usually a bad merge. The second one wins.
  • Invalid unit (error) — a number with an unknown unit, such as 12pz. The browser drops the declaration.
  • Shorthand (info) — all four margin-*, padding-*, top/right/bottom/left or corner radii could be one shorthand; overflow-x + overflow-y, row-gap + column-gap too.
  • Zero with unit (info) — 0px, 0em or 0rem can be just 0.
  • Unquoted font name (warning) — font-family: Helvetica Neue should be quoted.
  • Vendor-only property (info) — -webkit- or -moz- without the standard property in the same rule.
  • Empty rule (warning), unknown at-rule (info, a likely typo), more than five !important (warning), mixed-case hex colours (info), missing last semicolon (info), unclosed block (error), trailing whitespace and BOM (info).

HTML lint rules: unclosed or wrongly nested elements and stray end tags (error), duplicate ids, images without alt and obsolete tags such as <center> (warning), no lang on <html>, no doctype, inline on… handlers and end tags on void elements such as </br> (info). Inline <style> and <script> are linted too.

JavaScript lint rules: unbalanced brackets and unterminated strings, comments or templates (error), debugger, eval() and with (warning), == / != except against null, var and leftover console.log() (info).

From JSMin to Linters

Douglas Crockford’s JSMin, from the early 2000s, removed comments and unneeded whitespace from JavaScript and did nothing else, which made it safe; his JSLint checker dates from 2002. Yahoo’s YUI Compressor (2007) added CSS and shortened local variable names. Google open-sourced its Closure Compiler in 2009, and UglifyJS (2010) and its successor Terser (2018) brought syntax-tree minification to the Node.js build tools that most sites use today.

Linting grew alongside. CSS Lint, by Nicole Sullivan and Nicholas Zakas, appeared in 2011; Zakas went on to write ESLint in 2013, and stylelint followed in 2015. The compression side is older still: gzip was released by Jean-loup Gailly and Mark Adler in 1992, and its DEFLATE format was published as RFC 1951 in 1996. Servers apply it to text responses on the fly, which is why minified and gzipped sizes are both shown here.

About This Tool

This tool minifies, beautifies and lints HTML, CSS and JavaScript in one place; it also replaces the separate CSS beautifier, minifier and linter. Each language is split into tokens before anything is changed, so strings, template literals, regular expressions, url() values and <pre> or <textarea> blocks are left exactly as written. In HTML, inline <style> and <script> blocks are minified, beautified and linted with the CSS and JavaScript engines.

It does not rename variables or remove unused code, as Terser or cssnano do in a build pipeline. It is for one-off snippets, for reading minified code, and for checking a stylesheet before review. Everything runs in your browser; your code is never uploaded.

Related tools: JSON Formatter, HTML Page Auditor, and JavaScript Obfuscator.

Frequently Asked Questions

How much does minifying save?

It depends on how much of the file is comments and indentation. The 318-byte JavaScript example on this page drops to 170 bytes (46.5% smaller), because 84 bytes were comments. The 318-byte CSS example is already compact and only drops to 294 bytes (7.5%). Gzip on the server then shrinks the text again; the script goes from 224 to 156 bytes gzipped.

Will minifying break my code?

It should not. The code is split into tokens first, so the contents of strings, template literals, regular expressions, url() values and <pre> or <textarea> blocks are never touched. Spaces inside calc() are kept (calc(100% + 2rem) is invalid without them), and a line break is kept wherever removing it could change how JavaScript inserts semicolons. Variable names are not shortened, so nothing that depends on them can break.

What does the CSS linter check?

Duplicate properties in one rule (padding set twice), zero lengths with a unit (0px), unknown units such as 12pz, which make the browser drop the line, four longhands that could be one shorthand (margin-top, -right, -bottom and -left), unquoted font names with spaces, prefixed properties without the standard one, empty rules, unknown at-rules, more than five !important, mixed-case hex colours, a missing last semicolon, trailing spaces and a BOM. HTML and JavaScript have their own checks, such as unclosed tags, duplicate ids and unbalanced brackets.

Does it keep licence comments?

Only if you ask. With Keep licence comments ticked, CSS and JavaScript comments that start with /*! or //!, or that contain @license or @preserve, stay in the minified output, as the MIT and BSD licences require the copyright notice to travel with the code. HTML conditional comments (<!--[if IE]>) are always kept.

Should I still minify if my server uses gzip?

Yes, but expect a smaller gain than the raw numbers suggest. Gzip already squeezes repeated spaces well, so in the script example minifying saves 148 bytes before compression but 68 bytes after it (224 to 156). Comments are the part gzip cannot remove, which is why minified and gzipped together is still the smallest.

How do I use the HTML, CSS & JS Minifier, Beautifier & Linter?

Simply type your numbers and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.

Is it free? Does it work without internet?

Yes to both. It is free with no sign-up, and once the page has loaded it keeps working even with no internet.

Where does my data go?

Nowhere — every calculation runs on your own device. Nothing you enter is uploaded, logged, or stored.

Common Use Cases

Inline critical CSS

Minify the above-the-fold rules before pasting them into a <style> tag; the 318-byte button example becomes 294 bytes on one line.

Read a minified library

Beautify a one-line script from DevTools or a CDN into indented lines with one statement each, so you can follow what it does.

Review CSS before a merge

Lint a stylesheet to catch a property set twice after a bad merge, a typo such as 12pz, or a sixth !important.

Check pasted HTML

Lint an HTML snippet for unclosed <div> tags, duplicate ids and images without alt text before it goes into a CMS.

Shrink an email template

Minify the HTML of an email: comments go, <pre> blocks stay exactly as written and inline <style> is minified too.

Last updated: