XML Formatter
ConverterPretty-print and validate XML with custom indentation. Reports the line number for unclosed tags, missing quotes and undeclared namespace prefixes, and can.
Related Tools
About XML Formatter
XML is notoriously verbose, and output from APIs, logs, or legacy services usually arrives minified onto a single dense line. This tool formats (pretty-prints) and minifies XML entirely in your browser, and validates that tags are properly closed and nested so you catch malformed documents before they reach production. It handles XML declarations, processing instructions, CDATA blocks, namespace prefixes, comments, and self-closing tags. One important distinction: it performs well-formedness validation only — it will not enforce field types or business rules defined in an XML Schema (XSD) or DTD, which is the separate realm of validity checking. When a parse error occurs, the reported line and column help you locate the problem quickly. You can choose 2-space, 4-space, or tab indentation and switch between beautify and minify modes. Namespace prefixes are preserved so prefixed and default-namespaced children render as expected. Because everything runs locally, nothing is uploaded — safe for SOAP payloads, SVG files, Maven POMs, and Spring configs that contain sensitive data.
How to Use
- Open the XML Formatter tool
- Select the source and target formats
- Adjust the output options as needed
- Click the Convert button; results appear in real time
- Copy or export the result
Use Cases
- Beautify API messages — Format single-line SOAP/XML responses into an indented hierarchy to locate nodes fast.
- Validate well-formedness — Check that tags are paired and attribute quotes are complete to avoid runtime parse errors.
- Reduce transfer size — Minify development-time formatted XML to a single line to cut bytes.
- Analyze logs — Expand XML fragments copied from logs to inspect issues level by level.
- Review configs — Format pom.xml, web.xml, and other configs for easier code review.
- Compare XML diffs — Format both sides of an XML diff side-by-side to spot structural changes in config or payload files.
- Strip comments — Minify XML to strip comments and whitespace, producing a compact payload for production messages.
FAQ
Can it validate against XML Schema (XSD)?
No. It only checks well-formedness — closed tags and correct nesting — not XSD/DTD-based validity.
How many spaces for indentation?
Two spaces by default, producing clean, consistent output suited to most styles.
Are CDATA sections damaged?
No. CDATA content is preserved verbatim, without escaping or line wrapping.
Why a format error?
Common causes: unclosed tags, missing attribute quotes, multiple root nodes, or unescaped special characters. The error gives a location.
What is the difference between DTD and a Schema?
DTD is XML's early mechanism for declaring document structure and entities (verbose and limited typing); XSD describes structure in XML itself and supports data-type constraints. The tool validates neither against business rules.
Want JSON?
Use our XML to JSON tool.
Is there an XXE risk when parsing XML here?
No. An XXE (XML External Entity) attack happens when a parser follows DOCTYPE external entities to load local files or make unintended network requests, which can leak file contents or be abused for SSRF. This tool parses entirely in your browser via DOMParser, makes no network requests, and never loads DTD external entities, so there is no XXE or data-exfiltration risk here. That said, when you parse untrusted XML on your own server or application, explicitly disable external entity loading (for example, turn off NOENT and DTDLOAD in libxml) so you don't carry that class of risk into your production code.