XML Formatter & Validator
Developer Tools
Format or minify XML in your browser. Check well-formedness, inspect parse errors, and choose indentation; files stay on your device.
How to use this tool
- Paste XML into the input panel, open a local XML file, or drop one into the input area.
- Choose "Format / Beautify" or "Minify" mode.
- Choose an indentation style and optionally turn on Collapse text content or Strip comments.
- Review the formatted output and well-formedness status; use a reported line and column to jump to a parse error.
- Copy the result or download it as an XML file.
What is XML?
XML (Extensible Markup Language) is a structured text format for storing and transporting data. It is used extensively in configuration files, web services (SOAP, RSS, Atom), Android resources, Office Open XML documents, and many enterprise systems.
Why format XML?
Raw XML from APIs or generated files is often a single long line with no whitespace - completely unreadable. A formatter adds consistent indentation, making the document structure easier to inspect. It also checks well-formedness and reports errors like mismatched tags or missing quotes before the file reaches your application.
Format vs. Minify
Format mode adds indentation and line breaks for readability. Use it during development and debugging. Minify mode strips all unnecessary whitespace to reduce file size, useful for network transmission or embedding XML in build artefacts.
Common XML namespaces
Namespace declarations appear in XML as xmlns:prefix="URI" attributes. The three most
common ones you'll encounter:
-
xmlns:xs="http://www.w3.org/2001/XMLSchema"- XML Schema Definition (XSD), used to define the structure and data types of an XML document. -
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"- XML Schema Instance, used in XML documents to reference schema locations and declare nil values. -
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"- SOAP envelope namespace, present in every SOAP web service request and response.
XPath quick reference (not evaluated here)
XPath is the standard query language for selecting nodes in an XML document. This page provides a reference only and does not evaluate expressions. Key expressions include:
-
/root/child- selectchilddirectly underroot(absolute path). -
//element- select allelementnodes anywhere in the document. -
@attribute- select an attribute on the current node (e.g.,//img/@srcselects allsrcattributes). -
[predicate]- filter nodes (e.g.,//item[price>10]selectsitemnodes whosepricechild is greater than 10).
Removing XML comments
Turn on Strip comments to remove XML comments from either formatted or minified output. The option is off by default because comments may contain documentation that should be retained. CDATA sections and processing instructions are kept, including comment-like text inside CDATA.
XML vs. JSON
JSON has largely replaced XML for REST APIs because it is more compact and easier to parse in JavaScript. However, XML remains the right choice in several contexts:
- SOAP web services: all SOAP messages are XML by specification. Many enterprise and financial systems still use SOAP.
- Microsoft Office documents:
.docx,.xlsx, and.pptxare ZIP archives containing XML files - the Office Open XML standard. - Android resources: layouts, strings, and manifests in Android projects are all XML.
- RSS and Atom feeds: the syndication formats used by podcasts and news sites are XML-based.
Use JSON for new REST APIs and data interchange. Use XML when the target system, standard, or file format requires it.
Privacy
All processing runs in your browser using the native XML parser and the open-source xml-formatter library. Open a local XML, SVG, XSD, XSLT, RSS, Atom, WSDL, plist, or config file, or drop it into the input area. Files are decoded as UTF-8; large files may take longer because formatting runs on this page. Download creates an XML file on your device. Your XML is never uploaded to a server.
Frequently asked questions
What does "well-formed" mean for XML?
A well-formed XML document follows all XML syntax rules: every opening tag has a matching closing tag, tags are properly nested, attribute values are quoted, and there is exactly one root element. This tool validates well-formedness using the browser's built-in XML parser.
Does this validate against an XML Schema or DTD?
No - this tool checks structural well-formedness only. Schema validation (XSD, DTD, RelaxNG) is a separate process and is not performed here.
Does my XML leave my browser?
No. Pasted text and files opened here are read and processed in your browser. Download creates the formatted XML on your device; no XML is uploaded.
Can I open an XML file and save the result?
Yes. Open a local XML, SVG, XSD, XSLT, RSS, Atom, WSDL, plist, or config file, or drop it into the input area. Download saves the current formatted or minified output as an XML file.
What does Strip comments remove?
When enabled, Strip comments removes XML comment nodes from formatted or minified output. It is off by default; CDATA sections and processing instructions are preserved.
What is XML minification used for?
Minifying XML removes all unnecessary whitespace and newlines, reducing file size for transmission over the network - useful for API responses, config files embedded in builds, or anywhere bandwidth matters.
Related tools
- JSON ↔ XMLConvert structured data between XML and JSON when another system expects a different format.
- JSON FormatterFormat and validate JSON payloads that accompany an XML API response or config export.
- SQL FormatterFormat SQL queries for a database workflow that sits alongside your XML service config.
- YAML FormatterFormat YAML configuration files with consistent indentation for another common data format.
- HTML FormatterBeautify or minify HTML markup when cleaning a page template or copied fragment.
- JSON ↔ YAMLMove structured settings between JSON and YAML when a project uses both formats.