XML Formatter - Pretty Print, Minify & Validate XML Online

AdSense Placeholder
Slot: header_tool

XML Formatter

Indent, compress and check XML, with errors pointed out by line and column

AdSense Placeholder
Slot: tool_mid_article

Clean Indentation

Choose 2, 4 or 8 spaces or tabs. Attributes, comments, CDATA and the XML declaration are kept exactly.

Precise Error Messages

Mismatched tags, missing quotes, duplicate attributes and bad entities are reported with a line and column, and the spot is selected.

Minify Too

Strip the layout whitespace between elements to shrink a document without changing its text.

Full Privacy

Your XML is parsed in your browser and never uploaded.

Well-Formed XML in Brief

XML is strict. A document needs exactly one root element, every opening tag must be closed in the right order, attribute values must be in quotes and attribute names must not repeat on an element. The characters & and < in text must be written as entities, and comments cannot contain a double hyphen. This tool checks all of that and reports the first problem it finds.

Formatting is careful with text. Elements that contain only text are kept on one line as written, and elements that mix text with child elements, like a paragraph with bold words, are left exactly as they are, because changing whitespace there would change the document. This checks well-formedness only; it does not validate against a schema (XSD) or a DTD.

Key Takeaways

  • Safe for text: Text content and mixed content keep their exact whitespace.
  • Options: Optionally turn empty elements into self-closing tags and remove comments.
  • Related tools: See also XML to JSON, the HTML Formatter and the Sitemap XML Validator.
AdSense Placeholder
Slot: footer_leaderboard