XML Formatter

Paste XML to validate and pretty-print it in your browser. Pick your indent or minify, and get line-numbered errors when something is wrong. Nothing is uploaded.

  • Format
  • Minify
  • Validate with line numbers

Well-formedness check and pretty-print in this tab, with line and column numbers for every error. Choose 2 spaces, 4 spaces, or tabs, or minify. Nothing is uploaded.

Paste XML to validate it, pretty-print it with indentation, then copy or download the result.

An XML formatter turns a one-line feed, sitemap, or config file into readable, indented XML. Every nested element gets its own line and level, so you can scan the structure, spot a missing tag, and copy a clean version back into your editor.

The formatter is also an XML validator. It checks that the document is well-formed: one root element, tags that open and close in order, quoted attribute values, no duplicate attributes, and valid entities such as &. The first error is reported with its line and column. Valid input shows its element count, attribute count, nesting depth, and size in bytes.

Everything stays in this tab, with no upload and no account. Working with JSON instead? Use the JSON formatter or the HTML formatter. Tidy a query with the SQL formatter, read a token with the JWT decoder, or check structured data with the schema markup validator. More utilities live on the Developer hub.

How to use the XML formatter

  1. Paste XML into the box, or load the sample.
  2. Fix anything flagged as Invalid XML at the reported line and column.
  3. Choose Pretty-print or Minify and your indent.
  4. Copy the result or download it as a .xml file.
  5. Clear the box when you are done. Nothing is stored.

Frequently asked questions

What does an XML formatter do?

An XML formatter re-indents XML so every nested element sits on its own line at the right depth. It makes a one-line API response, sitemap, or config file readable without changing the data.

How do I format XML online?

Paste your XML into the box, choose 2 spaces, 4 spaces, or tabs, and press Format. The pretty-printed result appears below with a copy button and a download button.

How do I validate XML?

Paste it in. The tool checks that the XML is well-formed, which means one root element, matching and properly nested tags, quoted attribute values, no duplicate attributes, and valid entities. The first problem is reported with its line and column number.

What is the difference between well-formed and valid XML?

Well-formed XML follows the basic syntax rules. Valid XML is also checked against a schema such as an XSD or DTD. This tool checks well-formedness only, which catches the errors that stop most parsers.

How do I minify XML?

Switch Output to Minify. The tool removes the indentation and line breaks between tags and trims padding around text, so the file is as small as possible. Comments, CDATA sections, and attribute values are kept.

Why does my XML show an error at a line number?

The line and column point to where the parser first found a problem. Common causes are a closing tag that does not match, an unquoted attribute value, a stray ampersand that should be &, or a second root element. Fix that spot and the next error, if any, will appear.

Does formatting change my data?

No. Only whitespace between tags changes. Element names, attributes, text, comments, CDATA sections, and the XML declaration stay as you wrote them. Text that spans several lines is joined onto one line.

Is my XML sent anywhere?

No. Parsing and formatting run in your browser. Nothing you paste is uploaded or stored, so it is safe for internal configs and API responses.