XML Formatter & Validator

Beautify, minify and validate XML with selectable indentation and clear well-formedness checks. Everything runs in your browser — your data is never sent anywhere and nothing is stored.

How to use the XML formatter

  1. Paste or type your XML into the input box.
  2. Choose an indent size — 2 spaces, 4 spaces or a tab.
  3. Click Beautify to pretty-print it, or Minify to strip the whitespace between tags.
  4. The status line confirms Valid XML or shows the parser error, and you can copy the result.

Beautifying adds one level of indentation per nested element and places comments, <![CDATA[...]]> sections and the <?xml ?> declaration on their own lines. Minifying removes the whitespace between tags to produce a single compact line. Validation checks well-formedness only — matched tags, proper nesting, quoted attributes and a single root.

More PAYATE tools

Frequently asked questions

What does the XML formatter do?

It beautifies (pretty-prints) messy or minified XML by adding newlines and consistent indentation for every nesting level, and it can minify XML again by stripping the whitespace between tags. It also validates that the document is well-formed and reports the first error if it is not.

What does "well-formed XML" mean?

Well-formed XML follows the basic syntax rules: every opening tag has a matching closing tag (or is self-closed), tags are properly nested, attribute values are quoted, and there is a single root element. Being well-formed is not the same as being valid against a schema (DTD/XSD) — this tool checks well-formedness, which is what a browser parser enforces.

Is my XML sent anywhere?

No. Formatting, minifying and validation run entirely in your browser using the built-in XML parser — nothing is uploaded to a server and nothing is stored. It is safe for configuration, API payloads and other data you would not want to transmit.

Why does it say my XML is invalid?

The browser parser reports the document as not well-formed when it finds an unclosed or mismatched tag, an unescaped &, < or >, a missing quote around an attribute, or more than one root element. The red message shows the parser's own description so you can locate the problem.

Does it keep comments, CDATA and the XML declaration?

Yes. The beautifier preserves <?xml ... ?> declarations, processing instructions, <!-- comments --> and <![CDATA[ ... ]]> sections, placing each on its own indented line while leaving their contents untouched.

Can I choose the indentation?

Yes. Pick 2 spaces, 4 spaces or a tab from the indent selector, then click Beautify. Minify ignores the setting because it removes the whitespace between tags entirely.