Format and validate XML

Indent or minify XML and check that it is well-formed, with the line and column of the first error. Text, comments and CDATA stay exactly as written.

XML formatter in three steps

XML arrives on one line from an API, a log or a minified export, or with indentation that no longer matches its structure after a few hand edits. Formatting puts each element on its own line at the right depth so the structure can be read, and minifying does the reverse for a file that has to be small.

Formatting that leaves the content alone

Parsing the document into objects and writing it back out can reorder things, drop comments, change how characters are escaped, or add whitespace inside an element whose text matters. This one works on the text instead. Only the whitespace between elements changes. An element holding text stays on one line with its text untouched, and an element that mixes text with child tags, such as a paragraph with a bold word in it, is copied exactly, because in mixed content the spaces are part of what it says.

Checked before it is formatted

The XML is validated first. If a tag is not closed, closed in the wrong order, or an attribute is missing its quotes, the tool says so with the line and column of the first error instead of producing a formatted version of a broken file. Validation here means well-formedness; checking against a schema needs the schema, and is not attempted.

Stays on your device

Configuration files and API responses often carry credentials, tokens or customer records. The XML is parsed and formatted in this browser tab and is not sent anywhere.

  1. 1

    Paste the XML

  2. 2

    Choose the indentation or minify

  3. 3

    Format it and copy or download the result

Frequently asked questions

Does formatting change my data?

No. Only whitespace between elements changes. An element that holds text keeps that text exactly, an element that mixes text with tags is copied as written because the spaces in it are content, and anything marked xml:space="preserve" is left alone. Comments, CDATA sections and processing instructions are kept.

What does the validator check?

That the XML is well-formed, meaning every tag is closed in the right order, attributes are quoted and there is one root element. It reports the first problem with its line and column. It does not check the document against a schema or DTD.

Can it minify XML?

Yes. Choose Minify and the whitespace between elements is removed, with the same care over text, mixed content and preserved whitespace as indenting.

Is my XML uploaded?

No. Parsing and formatting happen in this browser tab, which matters for configuration files, API responses and exports that carry keys or personal data.

Related guides

Are online file converters safe? How to check whether a tool uploads your filesLearn how to tell whether an online converter uploads your file, inspect browser network activity, and evaluate privacy claims with evidence.