- Home
- Tools
- Text & Code
- XML Formatter
XML Formatter
Beautify, minify, and validate XML without resolving external entities.
DOCTYPE declarations are rejected. StackCache never resolves external entities or fetches XML resources.
Output
Formatted output appears here.Working notes
Use XML Formatter with the boundary visible.
XML Formatter indents, compacts, or validates XML while refusing external-entity resolution so formatting cannot fetch referenced resources.
What is XML Formatter?
XML (Extensible Markup Language) is a markup language for encoding structured data in a format that is both human-readable and machine-parseable. Unlike JSON, XML supports attributes on elements, mixed content (text interleaved with elements), namespaces, processing instructions, and document type definitions (DTDs). XML remains widely used in enterprise systems (SOAP web services, SAML authentication, Maven configurations), document formats (SVG, XHTML, Office Open XML), and data interchange (RSS/Atom feeds, GPX, KML). An XML formatter parses the document, verifies it is well-formed (properly nested tags, quoted attributes, escaped special characters), and rewrites the whitespace to produce consistent indentation. Minification strips all unnecessary whitespace, producing a compact single-line document for API payloads or configuration injection. This tool deliberately disables external entity resolution, preventing XXE (XML External Entity) attacks where a crafted document could cause the parser to fetch remote resources or read local files.
When to use it
- Debugging SOAP API responses — format verbose XML returned by enterprise web services to see the structure and find specific elements.
- Reviewing Maven or Gradle configuration — format pom.xml or build.gradle.kts embedded XML to check dependency declarations and plugin configuration.
- Inspecting SVG files — format SVG markup to understand the element hierarchy, attributes, and transforms before editing.
- Validating XML structure — paste XML from a log or API response to check whether it is well-formed before processing it with your application.
- Minifying configuration payloads — compact XML before injecting it into environment variables, Kubernetes ConfigMaps, or message queue bodies.
How to use it
- 01Paste the XML document into the editor.
- 02Select beautify (indent with consistent spacing), minify (strip all whitespace), or validate (check well-formedness without reformatting).
- 03Run the transform. If the XML is malformed, the tool reports the exact line and column of the first error.
- 04Copy the formatted output or download it as a .xml file.
Common mistakes
- Unclosed or mismatched tags — XML requires every opening tag to have a matching closing tag, and tags must nest properly. <a><b></a></b> is invalid.
- Unescaped special characters — ampersand (&), less-than (<), and greater-than (>) must be escaped as &, <, > in text content and attribute values.
- Missing XML declaration — while optional, the <?xml version="1.0" encoding="UTF-8"?> declaration prevents encoding issues, especially with non-ASCII characters.
- Confusing well-formed with valid — a well-formed XML document has correct syntax. A valid document also conforms to a schema (XSD or DTD). This tool checks well-formedness, not schema validity.
- Namespace prefix conflicts — using the same prefix for different namespaces or forgetting to declare a namespace causes parsers to reject the document.
Synthetic example
Indent nested elements
Input
<service><name>ledger</name><ready>true</ready></service>
Result
<service> <name>ledger</name> <ready>true</ready> </service>
Related standards
Limits and data boundary
- The formatter checks XML structure, not an XSD or business schema.
- External entities are not loaded or expanded.
Frequently asked questions
- Does the formatter resolve external XML entities?
- No. External entity resolution is deliberately disabled to prevent the formatter from making network requests to referenced URIs.
- Is my XML uploaded to a server?
- No. All parsing and formatting runs locally in your browser. The document never leaves your device.
- Can I minify XML for production use?
- Yes. Choose the minify mode to strip whitespace and produce a compact single-line document suitable for APIs or configuration payloads.
- Does this tool validate against an XSD schema?
- No. The tool checks that the XML is well-formed (correct syntax and nesting) but does not validate against an XSD, DTD, or Relax NG schema.
Keep working