Code tool

XML Formatter

Paste XML, choose readable indentation or compact output, and get a validated result without uploading your document.

In-browser processingNo account requiredPrivacy details ↗

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

A QUICK WALKTHROUGH

How to use this tool

  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.

GOOD TO KNOW

Common questions

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.