๐Ÿ”’ Runs in your browser โ€” nothing is uploadedโœ“ Free, no signup

XML Formatter & Validator

Paste XML to format it with clean indentation, check that it's well-formed, or minify it. Errors show the exact line and column so you can fix them fast.

Loading...

0 characters

Formatted XML

Loading...

When should you use the XML Formatter?

  • Reading minified XML from an API, SOAP response or config file
  • Finding the broken tag in an XML document that won't parse
  • Shrinking XML before sending or storing it

How to use the XML Formatter

  1. 1

    Paste your XML

    Paste a document or snippet into the input editor, or click Load sample.

  2. 2

    Choose Format or Minify

    Format adds indentation and line breaks. Minify removes the whitespace between tags.

  3. 3

    Check validation

    If the XML isn't well-formed you'll see the line, column and reason. Fix it and the output updates.

  4. 4

    Copy or download

    Copy the result or download it as an .xml file.

Examples

Minified XML to readable XML

Before

<catalog><book id="1"><title>XML Guide</title><price>44.95</price></book></catalog>

After

<catalog>
  <book id="1">
    <title>XML Guide</title>
    <price>44.95</price>
  </book>
</catalog>

Common errors and how to fix them

Expected closing tag 'b' instead of closing tag 'a'
Tags are closed in the wrong order or one is missing. Every opening tag needs a matching closing tag, and inner tags must close before outer ones.
Invalid character or unescaped &
Write & as &amp; and < as &lt; inside text and attribute values.
Multiple root elements
An XML document must have exactly one top-level element. Wrap everything in a single parent element.
Related tools:ย XML to JSON Converter ยท JSON to XML Converter ยท HTML Formatter

More from Code Formatters & Minifiers

Free tools that run in your browser โ€” no signup, nothing uploaded.

XML Formatter FAQ

It adds consistent indentation and line breaks so each element sits on its own line at the right depth. The data itself doesn't change โ€” only whitespace between tags.

Yes. Every input is checked for well-formedness โ€” matching tags, a single root element, quoted attributes and valid characters. Errors show the line and column. It does not validate against an XSD or DTD schema.

Yes. Comments, CDATA sections, processing instructions and the <?xml?> declaration are preserved. When minifying you can choose to remove comments.

Leading and trailing whitespace around text is trimmed so it lines up neatly. If whitespace inside an element is meaningful to your application, check the result before using it.

XML is a strict data format: every tag must be closed and names are case-sensitive. HTML is for web pages and is more forgiving. Use the HTML Formatter for HTML.

No. Formatting and validation run in your browser, so it's safe to paste internal API responses and config files.