Skip to content
Owais Khan Software Reviews

XML Formatter

Format, validate and minify XML. Runs in your browser — your XML never leaves your browser.

Format XML

Valid XML — root <catalog>, 11 elements, 4 attributes, 4 levels deep.

A formatter that doesn’t touch your data

Many online formatters “clean up” XML by trimming or collapsing the text inside elements, which silently changes the data — a problem for configuration files, SOAP messages and anything with significant whitespace. This one only rewrites the whitespace between tags. In the example, <description> mixes text with an <em> element, so it is left on one line rather than having line breaks inserted into its text.

XML validator: errors by line and column

Paste broken XML and the XML validator points to the first problem, with the offending line shown underneath and a caret at the column. It explains the error in plain words — which tag was left open and where, which attribute is duplicated, which ampersand needs escaping — rather than a parser’s internal message.

XML beautifier and minifier

As an XML beautifier it handles everything real files contain: the <?xml ?> declaration, namespaces, comments, CDATA sections, processing instructions such as stylesheet links, and DOCTYPEs with an internal subset. The minify XML button does the reverse, stripping layout whitespace for the smallest file that still parses to the same document.

Frequently asked questions

How do I format XML online?
Paste your XML or open a file, choose the indentation — 2 spaces, 4 spaces or a tab — and the formatted XML appears on the right as you type. Copy it or download it as a file. If the XML is not well-formed, the formatter tells you the line and column of the first problem instead of guessing.
Does formatting change my XML data?
No. Only the whitespace between tags — the layout — is rewritten. Text inside an element is kept byte for byte, so <name> Ada </name> keeps its spaces, and an element that mixes text with child elements, like a paragraph with <b> tags inside, stays on one line because indenting it would insert spaces into the text. Attribute values, CDATA sections and comments are copied exactly. Tick "Trim text" only if you want surrounding spaces removed.
How do I find an error in my XML?
The checker reports the first error with its position and a plain explanation — for example "Line 3, column 1: </a> does not match <b> opened at line 2, column 3." It catches mismatched and unclosed tags, a second root element, duplicate or unquoted attributes, a bare & or < in text, "--" inside a comment, and a misplaced <?xml ?> declaration. Fix that one and the next error, if any, appears.
What is the difference between well-formed and valid XML?
Well-formed XML follows the syntax rules every XML parser enforces: one root element, properly nested and closed tags, quoted attributes, escaped special characters. Valid XML is well-formed and also matches a schema — a DTD or XSD that says which elements may appear where. This tool checks well-formedness, which is what breaks parsers; schema validation needs the schema file.
How do I minify XML?
Click Minify. It removes the whitespace-only text between tags and, unless you tick "Keep comments", the comments too, while leaving all text content and attributes untouched. The result parses to the same document as the original.
Is my XML uploaded anywhere?
No. Formatting and checking run entirely as a small script inside this page; your XML never leaves your browser, and there is no upload, no API call and no analytics here. That is enforced rather than promised: this site’s test suite scans the shipped HTML for every browser API capable of sending data off the page and fails the build if it finds one.