Skip to content
CODE FORMATTING & MINIFICATION

CSS Formatter & Beautifier Online

Format CSS rules for readability.

  • 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 Formatter

About CSS Formatter

This CSS formatter reads minified or messy stylesheets and rewrites them with one declaration per line, two-space indentation and a space after each colon. Rules inside @media blocks are indented one more level, so responsive styles are easy to follow.

Missing semicolons after the last declaration of a rule are added, comments are kept, and strings are left untouched. Only whitespace changes; selectors, properties and values are not renamed, merged or reordered.

How to use CSS Formatter

  1. Paste your CSS into the input box.
  2. Click Run Tool to format it.
  3. Copy the result or download it as a text file.

Example

Input

.card{color:red;background:#fff;padding:16px}@media (max-width:600px){.card{display:none}} a:hover{color:blue;margin:0 auto}

Output

.card {
  color: red;
  background: #fff;
  padding: 16px;
}
@media (max-width: 600px) {
  .card {
    display: none;
  }
}
a:hover {
  color: blue;
  margin: 0 auto;
}

Common uses

  • Making a minified third-party stylesheet readable before debugging a layout issue.
  • Normalising styles copied from different sources into one consistent format.
  • Preparing CSS for a code review or a tutorial.

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

Does it sort or validate properties?

No. It formats what you give it. Typos in property names or invalid values are not detected.

Does it support nested CSS and media queries?

Yes. Blocks inside blocks, including @media and @supports rules and native CSS nesting, are indented by depth.

Can I get the compressed version again?

Yes. Paste the formatted CSS into the CSS Minifier to remove comments and whitespace.

Learn to build this yourself

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