Cette page n’est pas encore traduite en français : elle s’affiche en anglais.

CSS Formatter & Beautifier

Turn a minified stylesheet into readable CSS with one property per line and properly nested @media blocks. Works with CSS, SCSS and Less syntax.

Mis à jour le
 
Formatted CSS
 

Vos données ne quittent jamais votre ordinateur. Tout le traitement se fait localement dans votre navigateur.

Comment utiliser : CSS Formatter

  1. Paste your stylesheet into Input CSS, drop a .css file onto it, or click Sample.
  2. Pick the indentation and whether you want a blank line between rules and each selector of a group on its own line.
  3. Copy or download the formatted CSS. Switch to Minify when you need the compact version again.

What does a CSS formatter do?

A CSS formatter takes stylesheet code in any shape — minified onto one line, inconsistently indented, or copied from browser DevTools — and rewrites it with a predictable layout: the selector, an opening brace, one property: value; declaration per line, and the closing brace on its own line. Rules inside @media, @supports and @container blocks get an extra level of indentation so the structure is obvious.

Formatting is the first step when you need to debug a third-party theme, review CSS in a pull request or learn from another site’s styles. The formatter is powered by js-beautify and runs entirely in your browser.

Before and after

.btn,.btn-primary{display:inline-flex;padding:.625rem 1rem;color:#fff}@media (max-width:640px){.btn{width:100%}}

becomes

.btn,
.btn-primary {
  display: inline-flex;
  padding: .625rem 1rem;
  color: #fff
}

@media (max-width:640px) {
  .btn {
    width: 100%
  }
}

Note that the formatter does not add or remove semicolons, reorder properties or change values — it only changes whitespace, so the result behaves exactly like the input.

SCSS, Less and modern CSS

Nested rules, & parent selectors, variables ($brand, @brand), mixins and native CSS nesting are all indented correctly. Custom properties (--brand: #4f46e5), clamp(), :is()/:where() and cascade layers (@layer) pass through untouched.

Style conventions worth adopting

  • Two-space indentation is the de-facto standard in most CSS style guides and the Prettier default.
  • One selector per line in grouped selectors makes diffs smaller when you add or remove a selector.
  • A blank line between rules improves scanning in long files.
  • Keep formatting automatic: run Prettier or Stylelint in your editor and CI so formatting never shows up in code review.

Shipping to production? Use the CSS Minifier to see exactly how many bytes you save, or tick Minify above. To convert pixel values while you are at it, try the PX to REM converter.

Aussi recherché comme : css beautifier, css prettifier, format css, pretty print css, unminify css, css indent, scss formatter, less formatter.

Outils complémentaires : CSS Formatter

  • HTML Formatter — Paste minified or messy markup and get clean, consistently indented HTML — including embedded <style> and <script> blocks.
  • JavaScript Formatter — Unminify and pretty-print JavaScript, JSON or JSX with your preferred indentation and brace style — or strip whitespace and comments with a verified minifier.
  • Calculateur de colliers de serrage — Saisissez une taille minimale et maximale ainsi que la plage de la fenêtre d'affichage — obtenez une valeur adaptée au zoom clamp() , accompagnée d’explications mathématiques, d’un aperçu en temps réel et d’une échelle complète de la typographie fluide ou de l’espacement.
  • Color Converter — Paste any CSS color — HEX, rgb(), hsl(), hwb(), oklch() or a name like tomato — and get every other format instantly, plus a ready-to-use 50–950 palette.

Questions fréquentes

Does formatting CSS change how it works?
No. Only whitespace and line breaks change; selectors, properties and values stay exactly the same, so the browser applies identical styles.
Can I unminify a .min.css file?
Yes — paste it in or drop the file onto the input. Comments that were removed during minification can’t be restored, but the structure becomes fully readable.
Does it support SCSS and Less?
Yes, nesting, variables, mixins and & selectors are indented correctly. The tool formats the syntax but doesn’t compile SCSS or Less to CSS.
Is my CSS sent to a server?
No. Everything runs locally in your browser, so private or unreleased stylesheets never leave your device.
Should I use tabs or spaces for CSS?
Either works; consistency matters more. Two spaces is the most common choice in style guides and the default in Prettier, while tabs let each developer choose their own visual width.
Puis-je installer CSS Formatter en tant qu’application web et l’utiliser hors ligne ?
Oui. CSS Formatter est une application web installable (PWA) : elle s’installe depuis votre navigateur, sans passer par une boutique d’applications. Cliquez sur « Installer l’application » en haut de cette page dans Chrome ou Edge (Windows, macOS, Linux, ChromeOS) ; sur Android, utilisez « Partager » → « Ajouter à l’écran d’accueil » sur iPhone et iPad ; ou « Fichier » → « Ajouter au Dock » dans Safari 17+ sur Mac. L’application s’ouvre alors dans sa propre fenêtre avec sa propre icône, et comme elle s’exécute entièrement dans votre navigateur, elle continue de fonctionner hors ligne. Firefox sur ordinateur de bureau ne permet pas d’installer d’applications web. Comment fonctionne l’installation.

Outils similaires