XML

XML Formatter & Beautifier

Pretty-print messy XML with clean indentation, or minify it for transport — with validation built in.

Your XML is parsed and reformatted locally in your browser. Nothing is uploaded, logged, or stored.

1
Paste your XML here...
Formatted or minified output appears here

How to use

  1. Paste your XML into the input panel.
  2. Click Format to pretty-print with 2-space indentation, or Minify to strip all inter-tag whitespace.
  3. Copy the result or paste it back into your project.

How XML formatting works

Formatting happens in two steps. First the input is parsed with a strict XML parser — this doubles as validation, so malformed documents fail fast with a readable error instead of producing broken output. Then the parsed tree is re-serialized: Format mode indents each nesting level by two spaces and places every element on its own line; Minify mode removes all whitespace-only text between tags, producing the most compact representation.

Text content, attributes, comments-free structures, and the original XML declaration are preserved. Special characters are always re-escaped correctly, so the formatted output is semantically identical to the input — only the layout changes.

Need to check syntax without reformatting? Use the XML Validator. Working with JSON instead? The JSON Formatter & Validator does the same job for JSON documents.

Examples

Beautify API responses

SOAP and REST APIs often return XML as one long line. Format it to inspect nested elements, attributes, and values at a glance.

Minify config files

Shrink XML configuration or data files for embedding in URLs, logs, or payloads where every byte counts.

Normalize before diffing

Format two XML documents consistently before comparing them, so layout differences don't hide real content changes.

Frequently Asked Questions

Does formatting change my data?+
No. The document is parsed and re-serialized, so elements, attributes, and text content stay semantically identical. Only whitespace between tags changes.
Is my XML uploaded anywhere?+
No. Parsing and re-serialization happen entirely in your browser using the built-in DOMParser API.
What if my XML is invalid?+
The formatter validates as it parses and shows the error with line and column where available. Use the XML Validator for a dedicated syntax check.
Which indentation style is used?+
Two spaces per nesting level, which is the most common convention for data files. Attributes stay inline on their element's opening tag.
Can I convert the formatted XML to JSON?+
Yes — paste it into the XML to JSON Converter to get a JSON representation of the same document.

Related Tools

Looking for something else? Browse all tools