HCODX/XML Beautifier
100% browser-based · No data leaves your device

XML Beautifier

Beautify XML in your browser. Reformat compact or messy XML into clean, indented code. CDATA-safe, namespace-aware, all-local processing via your browser's native DOMParser.

XML input
Beautified output
Format options
Open in validator
Input size
0 B
Output size
0 B
Output lines
0
Status
Ready
Example

Messy in, clean out

Same data, structured for human eyes. Beautify expands compact XML into a line-per-element, properly indented document.

Compact XML
<root><item>one</item><item>two</item></root>
Beautified
<root>
  <item>one</item>
  <item>two</item>
</root>
Use cases

What you'll use this for

Anywhere unreadable XML shows up — feeds, config files, SOAP traffic, sitemaps.

RSS / Atom feeds

Pretty-print a feed before publishing or subscribing.

Config files

Reformat pom.xml, web.config, build descriptors.

SOAP envelopes

Tidy a SOAP request before sending.

Sitemaps

Indent sitemap.xml for review.

Step by step

How to beautify XML

1

Paste your XML

Drop it into the left editor. Compact, single-line XML works fine.

2

Pick indent

2 spaces by default. Switch to 4 spaces or tab to match your project style.

3

Click Beautify

Or leave auto-format on for live updates. Runs locally with DOMParser + XMLSerializer.

4

Copy or download

Copy to clipboard, save as .xml, or flip the Mode to Minify to compress back.

FAQ

Frequently asked questions

Yes. CDATA sections, comments, and processing instructions are preserved as-is.

Yes — choose 2 spaces, 4 spaces, or tab.

Yes. No signup, no limits, no ads.

No. Uses your browser's native DOMParser + XMLSerializer.

Yes — xmlns declarations and prefixed elements pass through unchanged.

About

About this beautifier

XML beautification is a one-pass operation: parse the input with the browser's native DOMParser, serialize it back through XMLSerializer, then walk the token stream to apply consistent indentation. The result is canonical — same structure regardless of whether the input was tightly packed, hand-typed, or pre-indented.

What it does

  • Indents at 2 spaces (default), 4 spaces, or tab.
  • One element per line for opening, closing, and self-closing tags.
  • Namespaces preserved. xmlns declarations and prefixed elements pass through untouched.
  • CDATA, comments, PIs kept verbatim — no whitespace inserted inside them.
  • Minify mode strips inter-tag whitespace to compact the document.

What it doesn't do

  • XSD / DTD validation. Well-formedness only. For schema checks use a dedicated XSD tool.
  • Lossy edits. No attribute reordering, no element removal. Round-trips back through any conformant XML parser.
  • HTML. XML mode is strict — unclosed tags or unquoted attributes raise a parse error. Use the HTML formatter for HTML.
Related

Related tools