XML Formatter & Validator

Beautify, minify, and validate XML. Everything runs in your browser, so your data never leaves the page.

About this XML formatter

This is a free online XML formatter and validator. Paste any XML document into the input panel and you'll get a tidy, syntax-checked version in the output panel. If the input is malformed, the tool points at the line and column where the parser failed.

Features

  • Format any XML with 2 spaces, 4 spaces, or tab indentation.
  • Minify XML to remove formatting whitespace for transport.
  • Validate well-formedness with line and column error reporting.
  • Preserve comments, CDATA sections, processing instructions, and the XML declaration.
  • Copy the result or download it as a .xml file.

How it works

Parsing uses your browser's native DOMParser, the same XML parser that powers web platform APIs. The tool walks the resulting DOM tree and re-emits it with your chosen indentation. Mixed content (text and elements together, like in HTML-flavored XML) is kept on one line so significant spacing is not lost.

Privacy

Your XML never leaves your browser. The whole tool runs locally as JavaScript on this page, so you can safely paste sensitive configuration, SOAP envelopes, manifests, or feeds without anything being uploaded.

Frequently asked questions

Does this tool send my XML anywhere?
No. All parsing, formatting, and validation happens in your browser using the native DOMParser. Nothing is sent to a server.
Does it validate against an XSD, DTD, or RelaxNG schema?
No. The tool only checks well-formedness (proper nesting, matched tags, valid syntax). Schema validation requires a heavyweight engine that is not bundled here. For that, use xmllint or an IDE plugin.
Are XML namespaces handled correctly?
Yes. Namespace prefixes and xmlns declarations are preserved on the elements where they appear, and re-emitted as written.
What survives a round-trip through the formatter?
Element structure, attributes, comments, CDATA sections, processing instructions, and the XML declaration are preserved. Insignificant whitespace between elements is normalized, and empty elements are collapsed to self-closing form.