Skip to content
cosmodev ~/tools/css-minify

تصغير وتجميل CSS

Converters & Formatters

صغّر CSS (إزالة التعليقات والمسافات البيضاء، واختصار قيم الألوان السداسية والأعداد العشرية) أو جمّله بالعودة إلى صيغة مقروءة بتصريح واحد في كل سطر. تبقى السلاسل النصية سليمة. يعمل محليًا في متصفحك مع رابط قابل للمشاركة.

جرّب:

(التوثيق بالإنجليزية)

What it does

Two directions, one parser. Minify strips comments and collapse whitespace, removes the last semicolon before }, lowercases and shortens hex colors (#FFEEAA → #fea), and trims decimal zeros (0.50em → .5em, 1.00 → 1). Beautify re-indents to readable form: one selector line per block, one declaration per line at 2-space depth. Strings (content: "…") and their contents are never touched — the parser knows quotes from syntax. Invalid input (an unterminated string or comment, unbalanced braces) produces a named error, never broken output. Everything runs locally in your browser.

How to use it

  1. Pick a direction with the Minify / Beautify switch.
  2. Paste CSS into CSS input (left), or tap a chip — Rules, Messy, Media query. Sample loads a mixed document; Clear empties the box.
  3. The result appears live on the right. In Minify mode a badge reports bytes before → after and the percentage saved.
  4. Copy takes the output; Download saves it as styles.css.
  5. Copy share link encodes your input and the mode in the URL.

Examples

Minify:

a { /* note */ color: #FFEEAA ; margin : 0.50em } → a{color:#fea;margin:.5em}

Beautify:

@media (min-width:600px){a{color:red}} →

@media (min-width:600px) {
  a {
    color:red
  }
}

Beautify keeps each declaration’s own semicolon: input written with a trailing ; keeps it, input without it does not.

What minify changes (and what it never touches)

Rule Example
Drop /* comments */ a{/*x*/b:c} → a{b:c}
Collapse whitespace, strip around {} ; : , > a { b : c } → a{b:c}
Drop last ; before } a{b:c;} → a{b:c}
Lowercase + shorten compressible hexes #FFEEAA → #fea; #feeaab stays
Trim decimal zeros 0.50em → .5em, 1.50 → 1.5, 1.00 → 1

Never touched: strings, sibling combinators (a + b keeps its spaces — required), unit suffixes (0px stays 0px; 0 is not always valid where a time is required), and 8-digit hexes with alpha (#ffeeddcc stays — shortening it would change the color).

الكود المصدري14 لغة

100% على جانب العميل · بياناتك لا تغادر متصفحك أبدًا. هل وجدت هذا مفيدًا؟ شاركه مع أحد زملائك.