Làm đẹp CSS với thụt lề gọn gàng, hoặc thu gọn để giảm kích thước tệp. Xử lý media query, calc() và chú thích giấy phép.
Cách dùng Định dạng CSS
Dán CSS của bạn vào ô đầu vào.
Chọn Làm đẹp để định dạng hoặc Thu gọn để nén.
Chọn kích thước thụt lề, rồi sao chép kết quả.
This is a CSS formatter that beautifies stylesheets with clean, consistent indentation, or minifies them to shrink file size. You choose the indent size for beautifying, and switch to minify when you want the smallest output.
Readable CSS is easier to scan, review and debug: when each rule and declaration is indented consistently, you can see selectors, nesting and the shape of your media queries at a glance.
Minifying is for production. It removes the whitespace and comments that browsers do not need, so the file downloads faster. On a large stylesheet the saving adds up, especially before gzip compression on the server.
The minifier is careful where it matters. It keeps the spaces around plus and minus inside calc(), so calc(100% - 30px) stays valid, and it only strips spaces around structural characters such as braces, colons and semicolons. It also handles nested media queries correctly.
License comments written in the /*! ... */ form are preserved, which is the standard convention for keeping copyright and license notices in minified output even when ordinary comments are removed.
Both beautify and minify run entirely in your browser, so your stylesheets never leave your device. The tool formats for readability and size; it does not validate that your CSS is correct.
Câu hỏi thường gặp
Không. Trình thu gọn giữ các dấu cách quanh dấu cộng và trừ bên trong giá trị, nên calc(100% - 30px) vẫn hợp lệ. Nó chỉ loại bỏ dấu cách quanh các ký tự cấu trúc như dấu ngoặc nhọn, dấu hai chấm và dấu chấm phẩy.
Chú thích thông thường bị loại bỏ để tiết kiệm dung lượng, nhưng chú thích giấy phép viết dưới dạng /*! ... */ được giữ lại, đây là quy ước chuẩn để giữ thông báo bản quyền.
Không. Cả Làm đẹp và Thu gọn đều chạy hoàn toàn trong trình duyệt của bạn, nên các stylesheet của bạn không bao giờ rời khỏi thiết bị.
Nhúng công cụ này
Thêm công cụ này vào trang web của riêng bạn. Sao chép đoạn mã bên dưới; nó tự động cập nhật.
<iframe src="https://monu.tools/embed/vi/css-formatter" width="100%" height="640" style="border:1px solid #e5e5e5;border-radius:12px;max-width:680px" loading="lazy" title="Monu Tools"></iframe>Công cụ liên quan
Làm đẹp HTML với thụt lề nhận biết khối, hoặc thu gọn nó. Nội dung của pre, textarea, script và style được giữ nguyên.
Làm đẹp và làm gọn JavaScript với thụt lề và khoảng cách nhất quán. Chạy hoàn toàn trong trình duyệt của bạn.
Chuyển CSV sang tệp Excel .xlsx và Excel trở lại CSV, hoàn toàn trong trình duyệt của bạn. Hoạt động theo cả hai chiều.
Tạo interface TypeScript từ một mẫu JSON, với kiểu lồng nhau, mảng và trường tùy chọn. Chạy trong trình duyệt của bạn.