XML formatter
Paste XML and get it neatly indented, or all on one line. The XML is checked by your browser's own XML parser, so an error shows the line and position where it goes wrong.
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.
Frequently asked questions
Is the XML formatter free?
Yes. The XML formatter is completely free, with no account, sign-up or usage limit.
Is my code stored?
No. Your code is processed in your browser and is not sent to a server or stored.
Does it work on my phone?
Yes. The tool works in any modern browser on a phone, tablet or computer.