Free Online XML Formatter and Validator, Pretty Print and Minify
Make XML readable or squeeze it back to one line, and find out exactly where it is broken. The error gives a line and a column rather than a vague complaint, and text mixed in with tags is left on one line so that indenting never changes what the document actually says.
Enjoying WizTools123? Help keep our server infrastructure 100% free and open for everyone.
Well Formed Is Not the Same as Valid
This page checks the first one, and says so plainly.
XML has two separate ideas of correct, and they get mixed up constantly. Well formed means the syntax holds together: every tag closes, they nest in the right order, attributes are quoted, there is exactly one root. Valid means the document also matches a schema, a DTD or an XSD, which says which elements are allowed where, how many there may be and what may go in them.
This page checks that it is well formed, using the browser's own XML parser. It does not check it against a schema, because that would mean fetching your schema from wherever it lives, and a page that sends your document somewhere is exactly what this set of tools is not. Most of the time "my XML is invalid" turns out to mean a missing closing tag or a stray ampersand, and that is the part this finds.
How to Format and Validate XML
A few steps, and nothing is uploaded.
What to Know About XML
Including the one thing most formatters get wrong.
<p>Hello <b>world</b></p> the space before the tag is part of your content. A formatter that indents that onto separate lines has quietly added whitespace to the text, and in XML whitespace inside an element is real. Any element that contains actual text is written on one line instead.
<?xml version="1.0"?> because it is not part of the document tree, so it is taken from your original text and put back on the first line unchanged, encoding and all.
& comes back as &, and a literal one that the parser accepted comes back escaped too. The document means the same thing; it is simply written the way XML requires.
Key Features & Capabilities
What this tool does, and what it deliberately does not.
About the XML Formatter
XML turns up in the places that have been running longest: SOAP responses, RSS feeds, configuration files, sitemaps, office documents, bank messages. It is verbose by design, and when it arrives with no line breaks it is genuinely unreadable. Indenting it by hand is not an option once it is more than a few hundred characters long.
This formats and checks it in your browser. Pick an indent, or minify it back down for transport, and get a count of what is in the document. The parsing is done by the browser's own XML parser, which is fast and exactly correct; the indenting is written here, because no browser will do that part for you.
The care went into one thing above all: not changing what the document says. Whitespace inside an XML element is content, not decoration, so any element that holds real text is left on a single line rather than being spread out prettily. That is the difference between a formatter you can run on a file you are going to ship and one you can only use to have a look.
Frequently Asked Questions
Well formed versus valid, mixed content, and where your error is.
Every Other Developer Tool
88 more tools in this set. All free, all in your browser.