About the XML Formatter
Tezmy's XML Formatter turns a wall of XML into neat, indented, readable code, or squeezes it into one compact line. Paste your XML and it is checked straight away: if a tag isn't closed, closed in the wrong order, an attribute isn't quoted, an “&” isn't escaped or there is more than one root element, you get a clear message with the line number. Choose 2 spaces, 4 spaces or tabs for indentation; short text stays on the same line as its tag so the result is easy to scan. Minify mode removes the whitespace between tags and, if you like, comments. It works with sitemaps, RSS feeds, SVG, config files, SOAP messages and Android layouts, and runs entirely in your browser.
Updated October 2026
How to use the XML Formatter
- 1Paste your XML into the left box (or press Example to try it).
- 2Choose Format or Minify, and the indentation you prefer.
- 3If there's an error, read the line number and message under the boxes and fix it.
- 4Copy the result or download it as a .xml file.
Common XML errors and how to fix them
- “Expected </a> but found </b>”: tags overlap; close the inner element before the outer one.
- “is never closed”: add the missing closing tag, or write it as self-closing: <tag/>.
- “A & must be written as &”: escape ampersands in text and attribute values.
- “XML can only have one root element”: wrap everything in a single parent element.
- “Attributes must look like name="value"”: put quotes around every attribute value.
Where you meet XML
- Website sitemaps (sitemap.xml) and RSS or Atom feeds.
- SVG images, which are XML you can open and edit.
- Office files (.docx, .xlsx are zipped XML) and Android layouts.
- SOAP web services, config files and data exports.
XML or JSON?
XML is common in older systems, documents and feeds; JSON is the usual choice for modern web APIs because it is shorter and maps straight onto JavaScript objects. If you work with JSON too, the JSON Formatter does the same job for JSON, and CSV to JSON converts spreadsheet exports. To compare two files use the Diff Checker, and the HTML, CSS & JS Minifier makes web code smaller.
Features
- Pretty print with 2 spaces, 4 spaces or tabs
- Minify, with or without comments
- Well-formedness check with line numbers
- Keeps CDATA, comments, DOCTYPE and the XML declaration
- Element count and nesting depth
- Copy or download the result
- Private: runs in your browser
Frequently asked questions
What does an XML formatter do?
It adds line breaks and indentation so each element sits on its own line, nested inside its parent. The data doesn't change, but people can read and edit it far more easily.
What makes XML “well-formed”?
Every element is closed (or self-closing like <br/>), elements close in the reverse order they opened, there is exactly one root element, attribute values are in quotes, the same attribute doesn't appear twice in a tag, and special characters such as & and < in text are written as entities (&, <).
Does it validate against a schema (XSD or DTD)?
No. It checks that the XML is well-formed, which catches most everyday mistakes. Checking against a schema, which says which elements are allowed where, needs the schema file and a full validator.
Will formatting change my data?
It changes only the whitespace between tags. Text inside elements is kept, though long text with line breaks is joined onto one line. For whitespace-sensitive content, such as mixed text and markup, compare the result before you use it.
Why minify XML?
Minified XML is smaller, so it loads and transfers faster, which helps for large feeds, API messages and files stored in databases. Keep a formatted copy for editing.
Is my XML uploaded?
No. Checking, formatting and minifying all happen in your browser, so configuration files and private data stay on your device.