What is an XML formatter?
XML is a markup format for structured data, used in RSS feeds, sitemaps, SOAP APIs, Android layouts, Office files, SVG images and countless configuration files. Generated XML often arrives with no line breaks, which makes it nearly impossible to read or debug.
An XML formatter, sometimes called a beautifier or pretty printer, indents each nested element on its own line. This one also validates: if the document isn't well-formed you get the parser's error instead of output, so it doubles as a quick checker. Minifying does the opposite, removing indentation to reduce size before sending or storing XML.
How to use the XML Formatter
1.Paste the XML
A config file, an API response, a feed or a sitemap.
2.Format or minify
Choose the indent, or collapse the document onto one line.
3.Fix any errors
If the XML is broken, the parser's message says what's wrong instead.
Example: a one-line book catalogue
A catalog element holding two books, each with an id, title, author, price and, for the second, an empty tags element:
- Elements
- 10
- Indent
- 2 spaces per level
- <title>Clean Code</title>
- kept on one line
- <tags></tags>
- written as <tags/>
Ten elements on one line become a readable tree with each book's details indented under it.
Checked by a real XML parser
The browser's XML parser reads the document strictly, so unclosed tags, mismatched names, unescaped & characters and missing quotes are caught. The output is rebuilt from the parsed tree, which means it's guaranteed to be well-formed.
Elements that contain only text stay on one line, empty elements are written as self-closing tags, and comments, CDATA sections and processing instructions are kept. Formatting trims the whitespace around text; for mixed content like XHTML paragraphs, check that spacing still reads correctly.
Frequently asked questions
What does well-formed XML mean?
Every tag is closed and properly nested, there's one root element, attributes are quoted and special characters are escaped.
Does it validate against an XSD or DTD?
No. It checks that the XML is well-formed, not that it follows a particular schema.
Is the XML declaration kept?
Yes. A leading <?xml version="1.0"?> line is kept at the top.
Can it format SVG files?
Yes. SVG is XML, so paste the file's code to tidy or minify it.
Related tools
JSON Formatter & Validator
Pretty-print, minify, sort and validate JSON with line-numbered errors.
YAML Validator & Formatter
Validate and format YAML, or convert it to JSON.
HTML Beautifier & Minifier
Indent messy HTML or minify it for production.
CSS Beautifier & Minifier
Format CSS readably or minify it safely.
JavaScript Beautifier & Minifier
Format JavaScript, or minify it with Terser.
SQL Formatter & Beautifier
Beautify or minify SQL for MySQL, PostgreSQL, SQL Server and more.
More Developer tools
JSON & data
CSV tools
Network & system
Web & API
Git & releases
Encoding & security
- Base64 encode & decode
- URL encode & decode
- JWT decoder
- Hash generator
- HTML entity encoder
- Text to binary
- Morse code translator
- Caesar cipher & ROT13
- Random string generator
- Secret key generator
- 2FA code generator (TOTP)
- Encrypt & decrypt text
- Encrypt & decrypt files
- SSH key generator
- Base32 encoder and decoder
- Unicode escape converter
- Nano ID generator
- JWT generator
Text & code
- Regex tester
- Text diff checker
- Cron expression explainer
- Lorem ipsum generator
- Markdown previewer
- Slug generator
- Strip HTML tags
- Unicode character inspector
- URL parser
- Markdown TOC generator
- cURL converter
- Whitespace visualizer
- Markdown link extractor
- Regex escape
- Regex match extractor
- Split text by regex
- HTML, CSS and JS playground
- Mock data generator
- Keyboard event tester
- ASCII table