พัฒนาเว็บ
CSS Minify / Beautify
บีบอัด CSS สำหรับ production หรือจัดรูปแบบ CSS ที่บีบอัดแล้วให้อ่านง่าย
ใหญ่เกินไปสำหรับการแสดงตัวอย่าง
ใหญ่เกินไปสำหรับการแสดงตัวอย่าง
Minifying CSS strips whitespace, comments, and line breaks that only exist for human readability and have no effect on how a browser applies styles. The result is a smaller file and a faster page load.
How to use it
- Minify: paste CSS and the tool strips unnecessary whitespace, comments, and line breaks while keeping behavior identical.
- Beautify: paste minified CSS with no indentation to get a readable version back, with indentation and line breaks.
- Handy for quickly reading CSS from a third-party site that only ships a minified version.
Common uses
- Minifying CSS for production when there's no build tool (Vite, Webpack) set up, or for a quick one-off minification.
- Beautifying minified CSS from a third-party library to read or debug it.
- Estimating how much a CSS file will shrink before setting up an automated build.
Things to keep in mind
Minification never changes styling behavior — it's a purely syntactic transformation; if a page looks different after minifying, that's a bug in the tool, not an intentional change.
Without a source map, debugging minified CSS in production is harder — the line numbers shown in the browser console won't match the original file.
บทความเกี่ยวกับเครื่องมือนี้: การมินิฟาย CSS: อะไรถูกลบออกจากไฟล์บ้างและเพื่ออะไร
คำถามที่พบบ่อย
การย่อขนาดลบอะไรออกจาก CSS ของฉันจริง ๆ?
Minify ลบช่องว่าง การขึ้นบรรทัดใหม่ และคอมเมนต์ และย่อค่าบางอย่าง ลดขนาดไฟล์โดยไม่เปลี่ยนพฤติกรรมของ CSS
Beautify สามารถคืนรูปแบบเดิมของฉันได้อย่างสมบูรณ์แบบหรือไม่?
Beautify จัดรูปแบบ CSS ที่ย่อแล้วใหม่ด้วยการเยื้องและขึ้นบรรทัดใหม่เพื่อให้อ่านง่าย แต่ไม่สามารถกู้คืนคอมเมนต์หรือสไตล์เดิมของคุณได้ เพราะถูกลบไปแล้วระหว่างการย่อขนาด
การย่อขนาดปลอดภัยสำหรับ CSS ที่ถูกต้องหรือไม่?
ใช่ — สำหรับ CSS ที่ถูกต้องตามไวยากรณ์ การย่อขนาดจะลบเฉพาะอักขระที่ซ้ำซ้อนและไม่เปลี่ยนตัวเลือกหรือค่าคุณสมบัติเลย และทุกอย่างทำงานในเบราว์เซอร์ของคุณ
ถ้าเซิร์ฟเวอร์บีบอัดไฟล์ด้วย Gzip อยู่แล้ว ยังต้องมินิฟายอีกหรือไม่?
ต้อง — การมินิฟายและการบีบอัดแบบ Gzip/Brotli เสริมกันและกัน: การมินิฟายลดขนาดไฟล์ต้นฉบับก่อนการบีบอัด และ Gzip/Brotli บีบอัดผลลัพธ์เพิ่มเติมระหว่างการส่ง ดังนั้นทั้งสองรวมกันจึงให้ขนาดสุดท้ายที่เล็กกว่าการใช้เทคนิคใดเทคนิคหนึ่งเพียงอย่างเดียว
source map สำหรับ CSS ที่มินิฟายแล้วคืออะไร?
source map คือไฟล์แยกต่างหากที่แม็ปบรรทัดของ CSS ที่มินิฟายแล้วกลับไปยังโค้ดต้นฉบับที่จัดรูปแบบไว้ ทำให้เครื่องมือนักพัฒนาของเบราว์เซอร์แสดงหมายเลขบรรทัดและชื่อไฟล์ที่ถูกต้องขณะดีบัก แม้ว่าเวอร์ชันที่เผยแพร่จริงบน production จะเป็นเวอร์ชันที่มินิฟายแล้วก็ตาม