Tool Hub

XML 格式化

美化輸出、壓縮並驗證 XML 文件

格式化 XML 文件 — 可設定縮排的美化輸出,或移除標籤間空白進行壓縮。驗證使用瀏覽器內建的 DOMParser。

輸出
<?xml version="1.0" encoding="UTF-8"?>
<library>
  <book id="1">
    <title>
      1984
    </title>
    <author>
      George Orwell
    </author>
  </book>
  <book id="2">
    <title>
      Brave New World
    </title>
    <author>
      Aldous Huxley
    </author>
  </book>
</library>

使用方法

  1. Paste your XML document into the input.
  2. Choose Pretty-print to indent the tree or Minify to collapse it to a single line.
  3. The document is validated with the browser's DOMParser, and any syntax error is reported with its location.
  4. Copy the result; everything is processed in your browser.

範例

  • Pasting <root><item id="1">a</item><item id="2">b</item></root> and pretty-printing nests each <item> on its own indented line under <root>.
  • If a closing tag is missing, the DOMParser check reports the line and column of the error so you can fix malformed XML quickly.

生產環境使用前請驗證輸出。無擔保 — 參見 條款.