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.
Cách dùng Định dạng HTML
Dán HTML của bạn vào ô đầu vào.
Chọn Làm đẹp để thụt lề 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 an HTML formatter that beautifies markup with block and inline aware indentation, or minifies it by collapsing whitespace and stripping comments. You pick the indent size when beautifying.
Beautifying indents elements according to how they nest, so the structure of a document, which elements contain which, becomes obvious. That makes hand-written or generated HTML far easier to read and debug.
Both beautify and minify run entirely in your browser, so your markup never leaves your device.
It deliberately leaves the contents of pre, textarea, script and style untouched, because whitespace inside those elements is significant: reformatting them would change preformatted text, what users type, or the meaning of your code.
Minifying removes comments and collapses runs of whitespace, which trims the file size browsers have to download. It is most useful as a build step for production pages.
The minifier keeps a single space between tags rather than removing it entirely, because whitespace between inline elements is actually rendered, and dropping it can shift your layout. This caution avoids the subtle visual bugs aggressive minifiers can cause.
Câu hỏi thường gặp
Nó thụt lề các phần tử dựa trên cách lồng nhau và cấu trúc của chúng, đồng thời để nguyên nội dung của pre, textarea, script và style, vì khoảng trắng ở đó có ý nghĩa.
Nó loại bỏ chú thích và gộp các chuỗi khoảng trắng thành một dấu cách. Nó giữ một dấu cách giữa các thẻ thay vì loại bỏ chúng, vì khoảng trắng giữa các phần tử nội tuyến được hiển thị và bỏ nó đi có thể làm dịch chuyển bố cục.
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 mã đánh dấu 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/html-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 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.
Chuyển JSON sang XML và XML trở lại JSON, theo cả hai chiều, hoàn toàn trong trình duyệt của bạn.