XML Formatter & Validator
Beautify, minify and validate XML right in your browser, with 2-space, 4-space or tab indentation, preserved attributes and comments, and instant error reporting.
XML Formatter & Validator — Paste XML to pretty-print it with 2-space, 4-space or tab indentation, or minify it onto a single compact line. The syntax is validated as you type and the first error is reported with its line and column. Everything is parsed entirely in your browser and never uploaded.
What is XML Formatter & Validator?
A free online XML formatter, beautifier, and validator that runs entirely in your browser. Paste minified or messy XML and the Beautify mode re-indents the document with your choice of 2-space, 4-space, or tab indentation, preserving attributes, the XML declaration, comments, and CDATA sections. Switch to Minify mode to strip the whitespace between elements and collapse everything onto one compact line for transport or storage. As you type it validates the markup with a strict parser, and a Status readout shows Valid XML or flags the first error with its line and column. Developers use it to read and debug SOAP, RSS, sitemaps, SVG, Android layouts, and configuration files, and to clean up API responses before committing them.
How to use XML Formatter & Validator
- Paste or type your XML into the Input box.
- Leave the mode on Beautify to indent the document, or click Minify to collapse it onto a single line.
- Pick your indentation from the dropdown: 2 spaces, 4 spaces, or a tab.
- Check the Status card - it reads Valid XML, or shows Invalid with the line and column of the first error.
- Use the Copy button to grab the formatted output, or click Clear to empty the input and start over.
Examples
Beautify a one-line document (2 spaces)
Input
<note><to>Tove</to><from>Jani</from></note>
Output
<note> <to>Tove</to> <from>Jani</from> </note>
Minify a configuration file
Input
<config> <debug>false</debug> <port>8080</port> </config>
Output
<config><debug>false</debug><port>8080</port></config>
Catch an unclosed tag
Paste <a><b>x</a> and the Status switches to Invalid, reporting the mismatched closing tag together with the line and column of the problem so you can jump straight to it and fix the markup.
Frequently asked questions
- Is my XML uploaded to a server?
- No. Parsing, beautifying, minifying, and validation all happen locally in your browser. Your data never leaves your device, and the tool keeps working offline.
- What indentation options can I use?
- In Beautify mode you can re-indent with 2 spaces, 4 spaces, or a tab character, chosen from the dropdown. Minify mode ignores indentation and removes the whitespace between elements to produce a single line.
- Does it keep attributes, comments, and CDATA?
- Yes. The formatter preserves element attributes, the XML declaration, comments, and CDATA sections, and keeps the sibling order of your nodes intact. It re-indents the structure without changing the data.
- Why does it say my XML is Invalid?
- The validator reports the first syntax problem and appends its line and column. Common causes are a tag that is never closed, a closing tag that does not match the one it opened, a missing quote around an attribute value, or more than one root element.
- Does it re-validate automatically?
- Yes. Validation and formatting update as you type, so the moment you fix the flagged spot the Status flips back to Valid XML and the output refreshes instantly.
Related tools
Base32 / Base58 Encode / Decode
Encode text to Base32 (RFC 4648) or Base58 (the Bitcoin alphabet) and decode either one back to text, fully UTF-8 safe and entirely in your browser.
Base64 Encode / Decode
Encode text to Base64 or decode Base64 back to text (UTF-8 safe).
Case Converter & Counter
Change text case and count characters, words and lines.
Code Formatter & Minifier
Beautify or minify HTML, CSS and JavaScript instantly in your browser, with 2-space, 4-space or tab indentation and Terser-powered JavaScript compression.