XML Formatter & Validator

Paste XML. Get it indented or minified, and a precise error if it isn't well-formed. Everything stays in this tab.

Pretty print · minifyWell-formedness checkNamespaces preservedNothing uploaded

Formatter

XML Viewer Chrome extension

Want this on every XML page you open?

The XML Viewer Chrome extension turns any XML page — feeds, sitemaps, API responses, config files — into a collapsible, colour-coded tree with search, in one click. Paste and open files too. Free, no data leaves your browser.

  • Collapsible tree with element, attribute and text colouring
  • Search that expands the path to each match
  • Formatted text view, copy and download
  • Two permissions, no analytics
Get XML Viewer for Chrome

Free · Chrome Web Store · by Miso Developments

Well-formed vs valid

XML has two levels of correctness, and this page checks the first. Well-formed means the document follows the syntax rules: one root element, every tag closed, tags properly nested, attribute values quoted, and the five special characters (< > & " ') escaped where they appear in text. Valid means it also conforms to a schema (XSD, DTD or RelaxNG) that says which elements and attributes are allowed where. A document can be perfectly well-formed and still invalid against its schema; conversely, nothing can be valid unless it is well-formed first. The error message here comes from the browser's parser and points at the line where it gave up.

Common well-formedness errors

An unescaped ampersand in text or a URL (& must be written &amp;); a < in text; a tag opened as <Item> and closed as </item> — XML is case-sensitive; an attribute without quotes; two root elements, often from concatenating two documents; and a stray byte-order mark or whitespace before the <?xml declaration, which must be the very first thing in the file if it's present.

What formatting changes and what it doesn't

Pretty printing adds indentation and line breaks between elements and leaves everything else alone: attribute order, namespaces and prefixes, comments, processing instructions and CDATA sections are preserved. Whitespace-only text between elements is treated as insignificant and normalised — which is what you want for readability, and what you must be careful about if your XML uses mixed content where whitespace matters (some document formats do). Minifying does the reverse: it removes insignificant whitespace so the document is as small as possible for transfer.

Privacy

The XML never leaves your browser — the parsing and formatting is done by the browser's own XML engine on this page, and there is no server to send it to. That matters when the XML is a SOAP response, a config file with credentials, or a customer data export.

Questions

It says 'error on line 1' but my XML looks fine

Check for anything before the declaration: a space, a blank line or a BOM. The declaration must be first, or leave it out entirely.

Does it validate against my XSD?

No — this checks well-formedness only. Schema validation needs the schema file and a validator such as xmllint or your IDE.

Why did my attribute order change?

It shouldn't; attributes are output in document order. If the source has duplicates, the parser rejects the document as not well-formed.