代码、数据与二维码工具

XML格式化器

在浏览器中处理或呈现XML格式化。

优先本地处理无需注册隐私说明 ↗

Up to 200,000 characters. Parsing and formatting happen locally in your browser.

使用步骤

如何使用

  1. Paste XML and choose pretty print or compact output.
  2. Select two spaces, four spaces, or tabs, then format the document.
  3. Review the validated result, copy it, or download an XML file.

Validated in your browser

The formatter uses the browser XML parser before producing output. It does not fetch external entities, resolve URLs, or send your XML to a server. Parser errors include a line and column when the browser exposes them.

Boundaries stay visible

XML declarations, processing instructions, comments, CDATA sections, doctypes, and text are handled as separate tokens. CDATA content is kept as CDATA instead of being escaped into ordinary text.

Readable or compact output

Pretty print uses your selected indentation and keeps mixed text content on one line where possible. Compact output removes formatting whitespace between markup while preserving meaningful text, comments, and CDATA.

常见问题

你可能还想知道

Is my XML uploaded?

No. Parsing, formatting, copying, and download preparation happen locally in your browser.

Can I preserve comments and CDATA?

Yes. Valid comments and CDATA sections remain in the output with their boundaries intact.

What happens when XML is invalid?

The result is not generated. The page reports the parser message and line or column when available.

Does compact mode change text?

It removes formatting whitespace between tags, while preserving text nodes, comments, CDATA, declarations, and processing instructions.