Skip to content
Toolcroft

Developer Tools

XML Formatter & Validator

Format, beautify, or minify XML online. Validates well-formedness, highlights errors, and supports custom indentation - all in your browser.

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 immediately obvious. It also validates well-formedness and flags 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

XPath is the standard query language for selecting nodes in an XML document. Key expressions:

  • /root/child - select child directly under root (absolute path).
  • //element - select all element nodes anywhere in the document.
  • @attribute - select an attribute on the current node (e.g., //img/@src selects all src attributes).
  • [predicate] - filter nodes (e.g., //item[price>10] selects item nodes whose price child is greater than 10).

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 .pptx are 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. Your XML is never uploaded to any server.