XML formatter
Format and validate XML in your browser: nothing is uploaded, there is no limit on the size, and an error shows the line and position where it goes wrong. Indent with the size you prefer, or minify to one line.
How it works
-
Paste your code
Paste the code in the left box or open a file. No code to hand? Click Example.
-
Instant result
The result appears as you type. If there is an error, you see the line and character.
-
Copy or download
Copy the result with one click or save it as a file for your editor or project.
What is checked?
Every opening tag needs a matching closing tag, attributes need quotes, there can be only one root element and characters such as & must be written as &. If something is wrong, you see the parser's message instead of a half-formatted result.
What stays the same?
Element names, attributes, text, comments, <![CDATA[ … ]]> sections and the <?xml … ?> declaration all stay intact. Only the whitespace between elements changes. Elements that contain just text stay on one line, such as <title>Max Havelaar</title>.
Indent with 2 or 4 spaces or a tab, or put everything on one line to minify. For HTML, which is less strict, use the HTML formatter.
Files that are XML underneath
RSS and Atom feeds, sitemaps, SVG images, Office documents (inside the ZIP), Android resources, Maven pom.xml files and many SOAP and payment messages are all XML. Format one here to read its structure, find the element you need or spot the missing closing tag.
Namespaces
Prefixes such as xsi: and xmlns: declarations are kept as they are. The formatter checks that the document is well formed, which includes namespace prefixes that are declared, but it does not validate against an XSD or DTD. Well formed means it can be read; valid means it follows a specific schema.
Whitespace matters in some places
In document-style XML, such as XHTML or DocBook, whitespace in text can be meaningful. The formatter only changes whitespace between elements and leaves text content alone, so mixed content such as <p>Hello <b>world</b></p> is not broken up.
HTML is less strict, so use the HTML formatter for web pages. For data in other formats, see the JSON formatter.
Frequently asked questions
Does it validate against an XSD?
No. It checks that the XML is well formed. Schema validation needs the schema file and a different tool.
Does it keep comments and CDATA?
Yes. Comments, CDATA sections and the XML declaration are kept as they are.
Why is my SVG or sitemap rejected?
It probably contains a character such as & that is not escaped, or a tag that is not closed. The message gives the position.
Is my XML uploaded?
No. It is parsed and formatted in your browser and never sent anywhere.