XML Formatter & Beautifier

Paste XML to lay it out with clean indentation, or squeeze it onto one line. The formatter checks that the XML is well-formed and points to the exact line and column of any mistake, with a plain-language explanation.

  • Free daily uses
  • Runs in your browser
  • No sign-up needed

Last updated

Plan: FreeView packages →

Processed in your browser. Your XML is not uploaded.

100 of 100 operations left today
XML input

Formatted XML

Guide

How to format and beautify XML

Three steps to turn a wall of XML into tidy, readable XML, and to find any mistake in it.

  1. Add your XML

    Paste XML into the XML input box, drop an .xml file onto it, or click Open file. Click Sample to try it with a small catalog. As soon as the XML is well-formed, you'll see ✓ This is well-formed XML under the box.

    The XML input box filled with a sample catalog on one line, with Open file, Sample and Clear buttons, and the message that it is well-formed XML.The XML input box filled with a sample catalog on one line, with Open file, Sample and Clear buttons, and the message that it is well-formed XML.
  2. Choose the layout

    Pick 2 spaces, 4 spaces, Tab or One line (minified). Tick Write empty elements as <tag/> to shorten empty elements, and untick Keep comments to leave comments out.

    The options bar with the Indentation menu set to 2 spaces and the checkboxes for empty elements and comments.The options bar with the Indentation menu set to 2 spaces and the checkboxes for empty elements and comments.
  3. Press Format XML

    The tidy XML appears on the right, with a summary of how many elements and attributes it has and how deep it goes. Use Copy or Download to take it with you. If the XML has a mistake, a message names the line and column; Go to error jumps straight there.

    The sample catalog on one line on the left and the same XML neatly indented on the right, with a summary line below.The sample catalog on one line on the left and the same XML neatly indented on the right, with a summary line below.

Good to know

  • Nothing is uploadedYour XML is processed in your browser and never leaves your device.
  • Daily usesEach successful run counts as one XML operation. XML with mistakes is never counted.
  • Text stays as writtenOnly the spaces between tags change. Text, entities, CDATA and comments are kept exactly.

Frequently asked questions

What does the XML formatter change?

Only the whitespace between tags: the indentation and line breaks. Element names, attributes (in their order and with their quotes), text, comments, CDATA sections, entities, processing instructions and the XML declaration stay exactly as you wrote them.

Will it change the text inside my elements?

No. Text is never trimmed or re-escaped. Elements that hold text next to child elements (mixed content), like <p>Hello <b>world</b></p>, and elements marked xml:space="preserve" are written exactly as they were, because their spaces are part of the data.

Does it check that my XML is valid?

It checks that the XML is well-formed: every tag is closed and properly nested, there is one root element, attributes are quoted and not repeated, and & and < are escaped. Any mistake is shown with its line and column and a short explanation. It does not validate against a schema (XSD) or DTD.

Can I minify XML with it?

Yes. Choose One line (minified) under Indentation to remove the whitespace between tags, and untick Keep comments to remove comments too. Text inside elements is not touched, so the data stays the same.

Why is &nbsp; reported as an error?

XML itself only defines five entities: &amp;, &lt;, &gt;, &quot; and &apos;. HTML names like &nbsp; or &copy; must be declared in the document's DOCTYPE, or written as character references such as &#160;. When the document has a DOCTYPE, the formatter accepts its entities and leaves them unchanged.

Is my XML uploaded or stored?

No. Everything runs inside your browser, so your data never leaves your device. Our server only records that one operation was done, along with your network address, so the daily limit shown above the tool can be applied.

More XML tools