XML Formatter & Validator
Beautify, minify, and validate XML documents. Works with SVG, RSS, SOAP, Atom, and any well-formed XML — all in your browser.
Beautify
Pretty-print XML with configurable indent. Preserves declarations, comments, CDATA sections, and processing instructions.
Minify
Strip insignificant whitespace and optionally comments. Element text and CDATA content are preserved exactly.
Validate
Check well-formedness using your browser's native XML parser. Reports the first syntax error with location.
Why format XML?
Machine-generated XML — API responses, build artifacts, exported data — usually arrives as one long line. Pretty-printing makes the element hierarchy visible at a glance, which is essential when you're inspecting a SOAP envelope, debugging an RSS feed, or diffing two SVG files in a code review.
Well-formed vs valid
Well-formedness is a syntactic property: every open tag has a matching close, attribute values are quoted, and the document has exactly one root element. Validity is a structural property defined by a schema (DTD, XSD, RELAX NG). This tool checks well-formedness — it will catch typos and broken markup, but it does not enforce that, say, an <item> must contain a <title>. For schema validation, run xmllint --schema or your platform's XML validator.
Preserved constructs
XML declarations (<?xml … ?>), DOCTYPE declarations, processing instructions (<?xml-stylesheet … ?>), comments, and CDATA sections are kept intact during beautification. Attribute order and quote style on each opening tag are preserved verbatim — only whitespace between elements is reflowed.
Frequently asked questions
›What does this XML formatter do?
It pretty-prints (beautifies), minifies, and validates XML documents. Beautify adds indentation and line breaks; minify strips whitespace and optionally comments; validate parses the document and reports the first well-formedness error.
›What's the difference between well-formed and valid XML?
Well-formed XML follows XML syntax rules: matching tags, properly quoted attributes, a single root element, and correctly escaped entities. Valid XML additionally conforms to a schema (DTD, XSD, RELAX NG). This tool checks well-formedness — schema validation requires the schema file.
›What kinds of errors will validation catch?
Mismatched or unclosed tags, multiple root elements, unquoted attribute values, illegal characters in tag names, unterminated comments or CDATA sections, invalid entity references, and most other syntactic issues a browser's XML parser detects.
›Does it support XML declarations, comments, CDATA, and processing instructions?
Yes. <?xml ... ?> declarations, <!-- comments -->, <![CDATA[ ... ]]> sections, <?xml-stylesheet ... ?> and other processing instructions, and DOCTYPE declarations are all preserved during beautification.
›What indentation options are supported?
Two spaces, four spaces, or a literal tab character. Choose whichever matches your team's style guide for SVG, RSS, configuration files, or other XML formats.
›Will minifying break my XML?
No. The minifier only collapses whitespace between elements and removes comments (optional). Text content inside elements and CDATA sections is preserved exactly. The result parses identically to the original.
›Can I format SVG, RSS, Atom, SOAP, or other XML dialects?
Yes — anything that is well-formed XML works: SVG graphics, RSS/Atom feeds, SOAP envelopes, XLIFF translation files, Maven pom.xml, Android resources, OPML outlines, and configuration files like web.config.
›Is empty-element collapse safe?
Yes for element content. <foo></foo> and <foo/> are equivalent in XML — the collapse option just chooses the shorter form. Disable it if a downstream consumer treats them differently (very rare).
›Is my XML uploaded anywhere?
No. Parsing, formatting, and validation all run in your browser. Your XML — including any sensitive data, API responses, or internal configuration — never leaves your device.
More free developer tools
Part of our growing tool belt — all client-side, all free.
JSON Formatter & Beautifier
Format, beautify, minify and validate JSON with sort keys, ASCII escape, and tree view.
Open toolJSON Validator
Strict JSON validator with precise error location, lint hints, structure stats, and duplicate key detection.
Open toolJSON Viewer
Interactive JSON tree explorer with filter, copy-path, expand/collapse all, and colour-coded types.
Open tool