Formatters
XML Formatter
Pretty-print and validate XML documents.
Frequently Asked Questions & Guide
How to use this XML Formatter
- Paste your XML into the input box, or click Sample.
- Choose your preferred indentation.
- Click Format to beautify, or Minify to strip whitespace for production transfer.
- Copy the result and paste it into your editor or config file.
This formatter uses @prettier/plugin-xml, which properly understands the XML grammar — including namespaces, processing instructions (<?xml version="1.0"?>), CDATA sections, and self-closing tags. The minify mode collapses whitespace between tags while preserving text content inside elements.
What is an XML Formatter?
XML (eXtensible Markup Language) is a markup language used for configuration files (Maven, Spring, NAnt), data interchange (SOAP, RSS, Atom, SVG), document formats (DOCX, ODF, XHTML), and many legacy enterprise APIs. Unlike JSON, XML has a rich grammar with attributes, namespaces, mixed content, and processing instructions — which means a naive regex-based formatter will frequently corrupt the document. A real XML formatter parses the document into a tree and re-emits it with proper indentation, which is exactly what this tool does.
Does it validate XML?
Yes, indirectly. If your input is not well-formed XML (unclosed tags, mismatched quotes, illegal characters), the parser will throw an error and the error message will be shown in the status line. Note that this is well-formedness validation, not schema validation — it does not check your XML against a DTD or XSD.
Does it handle SVG files?
Yes. SVG is XML and will format correctly here. If you want to also optimize the SVG (remove metadata, simplify paths, strip editor cruft), use a dedicated SVG optimizer like SVGO instead.
Will minify break my XML?
The minify mode removes whitespace between tags but preserves text content. For data-style XML (no mixed content) this is safe. For document-style XML with mixed text and elements (e.g. <p>Hello <em>world</em>!</p>), whitespace can be semantically meaningful — in those cases, prefer the Format mode.
Is my XML sent to a server?
No. Everything runs in your browser. Your XML never leaves your device.