UtilityKit

500+ fast, free tools. Most run in your browser only; Image & PDF tools upload files to the backend when you run them.

XML Formatter

Beautify and minify XML documents

About XML Formatter

XML hauled out of a log line is typically one giant string — this tool gives it back its tree shape so you can find the broken tag or read the feed without scrolling. Backend developers debugging SOAP envelopes, sysadmins reviewing legacy configs, and integration engineers tracing third-party XML payloads all benefit from formatted, indented XML. The formatter supports beautify and minify in the same tab: format for review, then minify for transport. CDATA sections are left untouched because their whitespace is meaningful, and comments stay attached to their parent elements. Namespace-prefixed elements like soap:Envelope indent correctly. When XML is not well-formed, the formatter reports the line and column of the error. Because it uses the browser's DOMParser, SOAP responses with tokens and financial data stay completely local.

Why use XML Formatter

Beautify and Minify in One Tool

Format XML for human review with indentation and line breaks, then minify it (all whitespace removed) to send over the wire or store compactly — both modes available in the same tab without switching tools or pasting twice.

CDATA and Comment Aware

Content inside CDATA sections is left completely untouched because its whitespace is semantically meaningful. HTML comments stay attached to their parent elements and are neither moved nor stripped during formatting.

Handles SOAP Envelopes

Namespaces like soap:Envelope, soap:Body, and xsi:type are preserved intact and indent exactly like any other element. Third-party SOAP responses format cleanly without namespace prefixes being stripped or mangled by the formatter.

Self-Closing Tag Detection

Empty elements written as <br></br> can be normalised to <br/>, or self-closing tags can be expanded to explicit open-and-close pairs — useful when your target parser or DTD requires a specific form.

Highlights Mismatched Tags

If an opening tag is never closed, or a closing tag has no matching opener, the line and column are flagged with a clear error message before any output is shown. Errors are reported by the browser's native XML parser for maximum accuracy.

Browser-Only Privacy

SOAP responses containing customer SSNs, authentication tokens, or financial transaction data are parsed by the browser native DOMParser running entirely in your tab. Nothing is uploaded, logged, or forwarded to any third-party server.

How to use XML Formatter

  1. Paste minified or messy XML into the input panel
  2. Choose Format (pretty-print) or Minify as the output mode
  3. Pick indent size: 2 spaces or 4 spaces (2 is most common for XML config files)
  4. Toggle self-closing-tag normalisation if you need <br/> instead of <br></br> or vice versa
  5. Read any syntax errors with their line and column number when the XML is malformed
  6. Copy the output or download it as a .xml file

When to use XML Formatter

  • Formatting a minified SOAP response from a third-party API to find the element causing a parsing error
  • Prettifying an RSS or Atom feed payload for debugging when the feed reader returns unexpected content
  • Minifying a large XML config before embedding it in a request payload or URL parameter where size matters
  • Reading a legacy server configuration file (Maven pom.xml, web.xml, Spring beans XML) that was never properly indented
  • Comparing two XML API responses by formatting both and using a diff tool to spot changed fields
  • Verifying an XML sitemap or manifest file is well-formed before submitting it to Google Search Console

Examples

Minified RSS feed → readable

Input: <rss version="2.0"><channel><title>Blog</title><item><title>Post 1</title><link>https://x.com/1</link></item></channel></rss>

Output: <rss version="2.0"> <channel> <title>Blog</title> <item> <title>Post 1</title> <link>https://x.com/1</link> </item> </channel> </rss>

SOAP envelope formatting

Input: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetUser><Id>42</Id></GetUser></soap:Body></soap:Envelope>

Output: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetUser> <Id>42</Id> </GetUser> </soap:Body> </soap:Envelope>

Minify pretty XML for transport

Input: <config> <db> <host>localhost</host> <port>5432</port> </db> </config>

Output: <config><db><host>localhost</host><port>5432</port></db></config>

Tips

  • If your XML starts with a BOM (byte-order mark, an invisible character), remove it — some parsers reject it and it will not display in the input but will still cause a parse error.
  • For very large XML feeds (over 2 MB), minify first and then re-format in smaller chunks — the browser's DOMParser holds the entire tree in memory simultaneously.
  • Always minify before posting XML to a SOAP endpoint — many WSDL-based services count whitespace bytes toward request size limits.
  • When debugging a third-party API, format two different responses and compare them side-by-side in a diff tool to spot which field changed between calls.
  • If you see odd strings like " in your XML, it may have been double-escaped — decode HTML entities once before formatting to see the original values.

Frequently Asked Questions

Is the formatter the same thing as an XML validator?
They overlap but are different. The formatter checks that XML is well-formed (tags match, attributes are quoted, etc.) and reports parse errors with line numbers. It does not validate against a schema (DTD, XSD, or Relax NG) — that requires a separate schema validator.
Will <![CDATA[]]> blocks be preserved untouched?
Yes. CDATA section content is treated as opaque text — the formatter does not parse, modify, or reindent anything inside a CDATA block. Whitespace inside CDATA is semantically significant and is left exactly as provided.
Does it handle SOAP namespaces like soap:Body correctly?
Yes. Namespace-prefixed elements and attributes (soap:Envelope, xsi:type, xmlns:xsd) are preserved as-is and indented the same as any other element. The formatter does not resolve or strip namespace bindings.
Can I minify XML to send over a low-bandwidth API?
Yes. Minify mode removes all whitespace between tags, producing a compact single-line output. The content and structure of the XML are unchanged — only insignificant whitespace nodes are removed.
What does 'well-formed' mean and does my XML need to be?
Well-formed XML follows basic structural rules: all tags are closed, attributes are quoted, there is exactly one root element, and special characters are escaped. The browser's DOMParser requires well-formed input to parse successfully. If your XML is not well-formed, the formatter shows a line and column error.
Will it convert <br></br> into <br/> automatically?
There is a self-closing normalisation toggle for this. When enabled, empty elements written as open-and-close pairs are rewritten as self-closing tags. This helps when matching legacy DTDs or XHTML requirements.
Why is my prolog (<?xml version='1.0'?>) showing up indented?
The XML prolog should always be at column zero and the formatter preserves this. If the prolog appears indented in the output, check that there are no characters (including a UTF-8 BOM) before it in the source — even a single space before the prolog makes XML technically invalid.
Is my XML uploaded anywhere?
No. The formatter uses the browser's native DOMParser API, which runs entirely in your tab. No network request is made and no data is sent to any server. SOAP payloads with authentication tokens or customer data are safe to paste.

Explore the category

Glossary

DOM tree
The in-memory tree structure that an XML or HTML parser builds from a text document. Each element, attribute, and text node becomes a node in the tree, which the formatter traverses to produce indented output.
Namespace
A mechanism for distinguishing XML elements from different vocabularies that might share the same name. Written as a prefix followed by a colon (soap:Body), with the prefix declared using an xmlns attribute.
CDATA section
A block wrapped in <![CDATA[ ... ]]> that tells the XML parser to treat its content as raw character data rather than markup. Used for embedding HTML or code snippets that contain characters like < and & without escaping them.
Self-closing tag
An XML element with no content written as <tagName /> instead of <tagName></tagName>. The two forms are semantically identical in XML, but some DTDs and parsers require one form over the other.
Prolog
The optional declaration at the very start of an XML document: <?xml version="1.0" encoding="UTF-8"?>. It must appear before any other content, including whitespace, to be valid.
Well-formed XML
XML that follows the basic structural rules of the XML specification: a single root element, all tags properly closed and nested, all attributes quoted, and special characters like < and & escaped. A document can be well-formed without conforming to any particular schema.