LESS FRICTION. MORE FLOW.

XML Formatter

Give nested XML room to breathe. Clean indentation, with mixed text and CDATA kept together.

Explore examples
No sign-up. No query uploads.

XML Input

0 charactersUTF-8 · XML
⌘ / Ctrl + Enter

Formatted XML Output

Waiting for your inputREAD ONLY

Ready when you are. Paste a query to get started.

1 MB input limit · No database connection required

Free to useNo account or subscription.
Content-aware formattingPreserves mixed content and CDATA.
Your browser, your codeInput stays in this page.

START WITH SOMETHING SMALL

XML examples

Load an example, then make it yours.

<catalog><book id="1"><title>Small tools</title><author>SnugDev</author></book></catalog>
<p>Hello <strong>developer</strong>, welcome.</p>
<example><![CDATA[<tag>literal text</tag>]]></example>

XML formatting that respects text content

This tool parses XML with the browser’s XML parser and indents element-only structures. It preserves mixed content and CDATA by serializing those elements without adding indentation inside them. This distinction matters: adding spaces around inline text can change what a document means to an application.

How to format XML

Paste XML or upload a UTF-8 .xml or .txt file up to 1 MB. Choose two spaces, four spaces or tabs and click Format XML. The output can be copied or downloaded as an .xml file. Malformed XML produces a browser parser message, and your original input stays available for correction.

Where whitespace is preserved

An element containing non-whitespace text, CDATA or xml:space="preserve" is serialized as a unit. Element-only children can receive indentation. The formatter does not attempt to infer rules from a schema. If whitespace-only text nodes are meaningful in your format, use xml:space="preserve" or retain the original document.

Serialization is not byte-for-byte preservation

The browser serializer may normalize empty-element notation, entity representation, namespace declarations and quotation details. The XML declaration may not be retained. Use this tool for readable working copies, not for digital signatures or workflows that require exact original bytes. Always keep the original file when formatting signed XML.

Supported input and explicit limits

Documents with a DOCTYPE declaration are rejected. The tool does not resolve external entities or fetch a DTD. It is not an XSD validator and does not verify business rules. Successful parsing indicates well-formed XML according to the browser parser, not conformance to a schema. Large or deeply nested documents may exceed browser limits despite meeting the file size restriction.

Examples worth trying

The element-only sample shows how nested records gain indentation. The mixed-content example keeps words surrounding an inline element together. The CDATA sample preserves literal markup text rather than interpreting it as child elements. Load any example above to inspect the behavior with your selected indentation.

A browser workspace for XML and SQL

XML processing uses the browser’s built-in parser and serializer. The enhanced editor loads separately from a CDN. This tool does not connect to a server to format your document. SnugDev also offers a SQL Formatter, SQL Beautifier, SQL Validator and SQL Minifier. See All Tools for the full list.

A FEW MORE SHORTCUTS

Keep your workflow moving

Browse all tools

GOOD TO KNOW

Frequently asked questions

Does formatting validate an XML schema?

No. The browser checks well-formedness only. This is not an XSD or DTD validator.

How does it handle mixed text?

Elements containing text or CDATA are serialized without inserting indentation inside them, preserving meaningful text spacing.

Can I format signed XML?

Use the original for signature checks. Browser serialization can change byte representation and invalidate signatures.

Are DOCTYPE declarations supported?

No. Documents containing a DOCTYPE are rejected. External DTDs and entities are not fetched.