XML Formatter & Validator
Format, beautify, and validate XML documents online. Handles namespaces, CDATA sections, and mixed content.
Last updated:
Paste XML above to format, indent, and validate it instantly. Namespaces, CDATA, and comments are preserved; only whitespace is normalized. Everything runs in your browser.
What is XML Formatter?
An XML formatter takes minified or messy XML and re-indents it with consistent nesting so the structure is readable. It also validates well-formedness — flagging unclosed tags, mismatched elements, and malformed attributes. XML remains common in SOAP APIs, RSS/Atom feeds, SVG, Android layouts, Maven POMs, and countless config files, making a reliable formatter a daily need.
How to format XML online
- 1Paste your raw or minified XML into the input pane.
- 2The tool re-indents it and reports any well-formedness errors.
- 3Choose your indent size (2 spaces, 4 spaces, or tabs).
- 4Copy the formatted XML into your editor, feed, or config file.
Use Cases
Read SOAP / API responses
SOAP and legacy APIs return dense XML on one line. Format it to inspect the envelope and body.
Clean up config files
Re-indent a Maven pom.xml, Android layout, or web.config that lost its formatting.
Debug RSS/Atom feeds
Pretty-print a feed to verify item structure and spot malformed elements.
Code Examples
Minified input
<note><to>Ada</to><from>Grace</from></note>Formatted output
<note>
<to>Ada</to>
<from>Grace</from>
</note>Key Concepts
- Well-formed vs valid
- Well-formed means syntactically correct (tags nest and close). Valid means it also conforms to a DTD or XSD schema. This tool checks well-formedness.
- CDATA
- A <![CDATA[ ... ]]> section holds text that should not be parsed as markup — useful for embedding code or HTML. It's preserved verbatim.
- Namespaces
- Prefixes like xmlns:soap disambiguate element names from different vocabularies. Formatting keeps them intact.
Tips & Best Practices
- ▸Whitespace between elements is normalized, but whitespace inside text nodes may be significant — verify mixed content.
- ▸CDATA and comments are preserved exactly; only inter-element indentation changes.
- ▸If validation fails, the first mismatched or unclosed tag is usually the real culprit — start there.
- ▸For huge XML documents, a streaming parser (SAX) in code scales better than loading everything into memory.
Frequently Asked Questions
Does the formatter preserve CDATA and comments?
Yes. CDATA sections and comments are preserved verbatim; only whitespace between elements is normalized to match the selected indent.
What indent options are supported?
2 spaces, 4 spaces, or tab characters. The choice is applied consistently at every nesting level of the output.
Related Tools
Regex Tester
Test regular expressions online. Live match highlighting, capture groups, and support for JavaScript flags (g, i, m, s, u, y).
SQL Formatter
Format and beautify SQL queries. Supports SELECT, JOIN, subqueries, CTEs, and multiple SQL dialects.
Case Converter
Convert text between camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, Title Case, and more.
Text Diff
Compare two text snippets side-by-side and highlight the differences. Word- and line-level diff, everything runs in your browser.
Word Counter
Count words, characters, sentences, paragraphs, and reading time in any text. Includes a byte-size estimate for storage planning.
Markdown → HTML
Convert Markdown to HTML with a live preview. Supports GitHub Flavored Markdown (tables, task lists, strikethrough) and code fences.