Skip to content
CODE FORMATTING & MINIFICATION

CSS Minifier – Compress CSS Online

Minify CSS by removing comments and whitespace.

  • Free
  • No signup
  • Runs in your browser

This tool runs in your browser. The text you enter is processed on your device and is not sent to NHP Learning.

CSS Minifier

About CSS Minifier

A CSS minifier shortens a stylesheet by removing comments, line breaks, indentation and the spaces around braces, colons, semicolons and commas. The last semicolon before a closing brace is also dropped because it is optional.

Smaller CSS files download and parse faster, which improves loading time. The tool changes whitespace only: it does not merge rules, shorten colour values or remove unused selectors, so the result behaves like the original.

How to use CSS Minifier

  1. Paste your CSS into the input box.
  2. Click Run Tool to minify it.
  3. Copy the result into your build output or a style tag.

Example

Input

/* card styles */
.card {
  color: red;
  background: #ffffff;
  padding: 16px;
}

@media (max-width: 600px) {
  .card { display: none; }
}

Output

.card{color:red;background:#ffffff;padding:16px}@media (max-width:600px){.card{display:none}}

Common uses

  • Compressing a small custom stylesheet for a WordPress theme or an email.
  • Embedding critical CSS inline in a page.
  • Checking how much of a stylesheet is comments and indentation.

Privacy and safety

This tool runs in your browser. The text you enter is processed on your device and is not sent to NHP Learning.

Frequently asked questions

Is the minified CSS safe to use?

For normal stylesheets, yes. Spaces around colons are removed, so avoid minifying selectors that rely on a space before a pseudo-class, and test the page afterwards.

Does it remove unused CSS?

No. Removing unused rules needs a tool that scans your HTML, such as PurgeCSS.

How do I make the CSS readable again?

Paste it into the CSS Formatter on this site.

Learn to build this yourself

Free tutorials and courses on NHP Learning cover PHP, JavaScript, SQL and WordPress, from the basics to real projects.