XML Formatter

Paste XML to check it is well formed and get it back neatly indented, or minified. If something is wrong you get the line and column. Text inside elements is never changed, and nothing is uploaded.

Free, no sign-up. Your XML stays in your browser.

Your XML

Up to 300,000 characters.

Paste XML and press Run.

How to

Check and format XML in three steps

  1. Paste your XML

    Drop in a document, a feed or a fragment with a single root element.

  2. Choose format or minify

    Format indents the elements. Minify removes the whitespace between them. Pick spaces or tabs and whether to keep comments.

  3. Fix any error, then copy or download

    If the XML is not well formed you get the problem with its line and column. Fix it and run again, then copy or download the result.

How whitespace is handled

  • In XML, spaces inside text can be data. This tool re-lays out only the whitespace between elements, comments and instructions.
  • An element that mixes text with child elements, such as a paragraph with a bold word, is printed exactly as written. So is any element marked xml:space="preserve".
  • Text, attribute values, CDATA and comments are never edited. Quote style on attributes is kept.
  • Well formed is not the same as valid. This tool checks the syntax, not a schema (XSD) or DTD.

FAQ

XML formatter questions

Is my XML uploaded anywhere?

No. The checking and formatting run in your browser and the page makes no network request with your data.

What does well formed mean?

It means the XML follows the basic syntax rules: every tag is closed and nested correctly, attribute values are quoted, there is one root element, and special characters such as & and < are written as entities. A well-formed file can still break the rules of a schema, which this tool does not check.

Will formatting change my data?

It should not. Text inside elements, attribute values, CDATA and comments are kept as written. Only whitespace between elements is changed, and elements that mix text and markup are left as they are. Compare the result if the whitespace in your document carries meaning.

What does minify do?

It removes the whitespace between elements and, if you choose, the comments. Text inside elements is kept as it is.

Does it validate against a schema or DTD?

No. It checks that the XML is well formed. Schema validation (XSD, DTD or RELAX NG) is not included, and entities declared in a DTD are accepted without being checked.

Is there a size limit?

Yes: 300,000 characters, and elements nested up to 200 levels deep. If you go over, you get a message saying which limit applies.