XML Formatter
Minified XML dumps from SOAP services, RSS feeds and config exports are unreadable in a single line. This formatter parses the document, rebuilds it with consistent indentation (2 or 4 spaces, tabs, or no indentation for minified output), preserves attribute order and CDATA sections, and reports any well-formedness issue with the exact line and column so you can fix mismatched tags without hunting.
How to format XML
-
1
Paste XML
Any length, any encoding; declaration is preserved.
-
2
Pick indentation
Spaces (2 or 4), tabs, or minify.
-
3
Format
The parser builds a DOM then re-serialises with consistent spacing.
-
4
Copy result
Output is well-formed XML ready to paste into logs or docs.
What formatting preserves
- XML declaration (
<?xml version="1.0" encoding="UTF-8"?>) kept verbatim. - DOCTYPE declarations and internal subsets preserved.
- Processing instructions (
<?xml-stylesheet ?>) kept on their own line. - Comments on their own line or inline depending on context.
- CDATA sections preserved exactly including whitespace inside.
- Attribute values re-quoted using double quotes if they contain no double quotes, single quotes otherwise.
- Entity references like
&,<,>left as-is unless you enable full entity expansion.
Indentation examples
Input (minified):
<books><book id="1"><title>1984</title><author>George Orwell</author></book></books>
Formatted (2 spaces):
<books>
<book id="1">
<title>1984</title>
<author>George Orwell</author>
</book>
</books>
Common errors the tool catches
| Error | Fix |
|---|---|
| Mismatched closing tag | Match opening and closing names |
| Unclosed element | Add the closing tag |
| Invalid character in tag name | Tag names must start with letter or underscore |
| Duplicate attributes on same element | Remove the duplicate |
| Malformed CDATA | Check <![CDATA[ and ]]> pairing |
Unescaped < or & in text |
Use < or & |
Well-formed vs valid
- Well-formed XML follows the syntactic rules: balanced tags, valid characters, proper nesting. The formatter checks this.
- Valid XML additionally conforms to a schema (DTD or XSD). For that, use the XSD validator.
An XML document can be well-formed without being valid, but not the other way around.
Practical notes
- XML attribute order is meaningful to some systems (not many modern ones), the formatter preserves input order.
- Self-closing vs explicit empty tags:
<foo/>and<foo></foo>are equivalent in XML; the formatter uses self-closing for empty elements unless you opt out. - Namespace prefixes are preserved exactly.
Frequently Asked Questions
Yes. Text inside mixed-content elements and CDATA sections is kept as-is; only whitespace between elements is adjusted for indentation.
Practical limit is around 50 MB in the browser. Beyond that, the DOM parse consumes too much memory. For huge files use a streaming formatter like xmllint on the command line.
Yes. Namespace declarations are preserved on their element; the formatter does not reshuffle them to the root unless you enable “consolidate namespaces”.
No. Parsing and formatting happens in your browser, nothing is transmitted.
Related Tools
Color Palette Generator
Generate monochromatic, analogous, complementary, triadic or tetradic color palettes from a base HEX color and export copy-ready CSS variables.
ASCII Table Reference
Full ASCII table from 0 to 127 with decimal, hex, octal, binary, standard names and HTML numeric-reference notation, including NUL, LF and DEL.
FPS Counter
Measure browser FPS with requestAnimationFrame, smoothing, min/max frame rate, warnings and an optional graph. Runs locally with no upload or API.
Color Wheel Explorer
Explore the colour wheel interactively. Rotate harmonies, compare HSL vs RYB, spot complementary and triadic pairs in real time.
HTML Character Reference
Searchable list of HTML entities, their named and numeric codes, and a one-click copy for special characters and symbols.
Keyboard Shortcut Reference
Search documented default keyboard shortcuts for VS Code, Chrome and Bash with GNU Readline on macOS, Windows and Linux.
Tool available in other languages
- XML-Formatter [DE]
- Formatador XML [PT]
- Định dạng XML [VI]
- XML-formaterare [SV]
- รูปแบบ XML [TH]
- XML Formatter [ID]
- XML 포매터 [KO]
- Formateador XML [ES]
- XMLフォーマッター [JA]
- مُنسّق XML [AR]
- Formateur XML [FR]
- XML-formatter [NL]
- Formater XML [PL]
- Formatter XML [IT]
- Форматтер XML [RU]
- XML Biçimlendirici [TR]
- XML 格式化工具 [ZH]