美化 XML 並加入適當縮排,或壓縮為單行。保留注解、CDATA 和處理指令。
如何使用 XML 格式化
將 XML 貼入輸入框。
選擇「美化」加入縮排,或「壓縮」進行壓縮。
選擇縮排大小,然後複製結果。
This is an XML formatter that beautifies a document with proper, depth-based indentation, or minifies it to a single line. It preserves comments, CDATA sections, processing instructions and the XML declaration.
Formatting runs entirely in your browser, so your data never leaves your device, which makes it safe even for XML that contains sensitive values.
XML is verbose and deeply nested. Indenting each element by its depth and putting tags on their own lines turns a wall of angle brackets into a structure you can actually follow.
It is useful across the many places XML still lives: SOAP responses, RSS feeds, build and config files, and document formats, where a quick reformat makes debugging far easier.
Beautifying keeps a single text child inline with its tags, so simple values stay compact, while the declaration, comments and CDATA are kept exactly as they were rather than being reflowed or dropped.
Minifying removes comments and the whitespace used only for indentation between tags. Text content and CDATA are kept exactly, so it is safe unless your document relies on significant whitespace in mixed content.
The tool reformats for readability and does not validate against a schema. Clean layout does not mean the document matches any DTD or XSD you expect.
常見問題
它根據巢狀深度縮排每個元素,將標籤放在獨立的行上,並保持單一文字子節點在行內。保留注解、CDATA 和 XML 宣告。
它會移除僅用於標籤之間縮排的注解和空白。文字內容和 CDATA 區段會完整保留,因此是安全的,除非您的文件依賴混合內容中的有意義空白。
不會。格式化完全在瀏覽器中進行,您的資料永遠不會離開裝置,即使 XML 包含敏感資料也很安全。
嵌入此工具
將此工具加入你自己的網站。複製下方的程式碼片段,它會自動保持最新。
<iframe src="https://monu.tools/embed/zh-Hant/xml-formatter" width="100%" height="640" style="border:1px solid #e5e5e5;border-radius:12px;max-width:680px" loading="lazy" title="Monu Tools"></iframe>相關工具