Developer tool

XML Formatter

Validate, format, or minify XML while keeping the document in your browser.

Practical guide

How to use XML Formatter

XML Formatter validates an XML document with the browser parser, then presents either an indented or compact serialization. It is intended for configuration files, feeds, API payloads, SVG source, and short document fragments where a readable structure makes mismatched elements or unexpected namespaces easier to diagnose.

Step by step

  1. Paste one complete XML document and select Validate and format.
  2. Read any parser error before using the normalized output.
  3. Review whitespace-sensitive text, namespace declarations, comments, and processing instructions before copying the formatted or minified result.

Example

Input<catalog><tool id="77"><name>XML Formatter</name></tool></catalog>
Result<catalog> <tool id="77"> <name>XML Formatter</name> </tool> </catalog>

How it works

The browser DOMParser reads the source as application/xml. A parser error stops conversion. Valid nodes are serialized back to XML, and the readable view inserts indentation between structural tags without contacting a schema service or fetching external resources.

Important limitations

  • Well-formed XML can still violate an XSD, DTD, namespace contract, or application-specific schema.
  • Pretty printing can add whitespace between elements, so mixed-content and digitally signed documents require special care.
  • The tool does not resolve external entities, download referenced resources, or execute embedded SVG scripts.

Real workflows

When this tool is useful

API payload diagnosis

Format a compact SOAP, RSS, Atom, sitemap, or custom XML response to find the element where nesting or namespaces differ from the receiving contract.

Configuration review

Validate a small application or build configuration before committing it, while keeping credentials and internal hostnames on the device.

Source comparison

Normalize two short XML fragments into a readable shape before comparing their structural differences in a text diff.

Review the result

What to check before using the output

Inspect the XML declaration, root element, namespace prefixes, attribute values, entity references, comments, CDATA, and whitespace-sensitive text. A successful parse proves only that elements and syntax are well formed.

  • Confirm one root document is present.
  • Validate against the real schema separately.
  • Review mixed-content whitespace.
  • Do not reformat signed XML casually.

Choose the right method

When another tool is better

Use an XSD-aware validator, application test suite, or specialized editor when schema rules, external entities, XPath, canonicalization, signatures, or very large streaming documents matter.

Privacy and browser behavior

Source and result remain in the browser tab. XML commonly contains credentials, internal URLs, customer identifiers, and signed data, so use synthetic samples in public issues and avoid formatting active secrets on an untrusted device.

Frequently asked questions

Does valid XML mean the data is accepted by my application?

No. This page checks well-formed syntax only; validate the result against the schema and business rules used by the receiving system.

Why did an empty element change shape?

Browser serialization may normalize equivalent syntax such as an explicit opening and closing pair versus a self-closing element.

Can I safely format signed XML?

Do not assume so. Canonicalization and whitespace can affect signatures; use the signing system's approved XML canonicalization workflow.