XML Formatter

Format, beautify, and validate XML documents.

Beautiful XML

Indent:
XML Input
Formatted Output

Features

Validate

Checks XML syntax

Format

Proper indentation

Minify

Remove whitespace

About

About the XML Formatter

The XML Formatter pretty-prints and validates XML in one pass — paste a wall of markup and get a cleanly indented document, or a precise error message if the XML doesn't parse. It's built to be lossless in the ways generic formatters aren't: CDATA sections, processing instructions, the DOCTYPE, and the original XML declaration are all preserved, mixed inline content stays inline instead of being re-indented into different semantics, and text is properly re-escaped on output. A minified version is generated alongside, indent width is adjustable, and the result can be copied or downloaded as a .xml file — all in your browser.

How to use the XML Formatter

  1. 1Paste your XML into the input area.
  2. 2Read the formatted output — or the validation error if the document doesn't parse.
  3. 3Adjust the indent width to your preference.
  4. 4Switch to the minified output if you need the compact single-line form.
  5. 5Copy the result or download it as a .xml file.

Common use cases

  • Making an unreadable single-line API response or SOAP payload readable
  • Validating a sitemap, RSS feed, or SVG before publishing it
  • Cleaning up configuration files (pom.xml, AndroidManifest.xml, .csproj)
  • Debugging a feed where a raw ampersand or unclosed tag breaks a downstream parser
  • Minifying XML for a payload where whitespace is wasted bytes

Frequently asked questions

Does it validate the XML too?

Yes — the document is parsed with a real XML parser first, so malformed markup produces a clear error message instead of confidently formatted garbage. Note this is well-formedness validation (syntax), not schema validation against an XSD or DTD.

Will it damage CDATA, DOCTYPE, or processing instructions?

No — that's this formatter's specific strength. CDATA sections, processing instructions, the DOCTYPE, and your original XML declaration are preserved through formatting, and mixed inline content (text with inline elements) stays inline rather than being broken across lines, which in XML can genuinely change meaning.

Can it minify XML as well?

Yes — a minified single-line version is produced alongside the pretty-printed one, useful when the XML is payload for an API call or a config value where size matters more than readability.

Is my XML uploaded anywhere?

No. Parsing and formatting run 100% in your browser — safe for config files, exports, and feeds that contain private data.