XML Formatter
Pretty-print and validate XML in your browser — RSS, SVG, sitemaps and config files.
How to use xml formatter
- Paste your XML into the input box.
- Choose an indentation — 2 or 4 spaces per level.
- Click Format to pretty-print the document in the output box.
- Click Validate to check well-formedness; errors name the offending tag.
- Copy the formatted output with the Copy output button.
Examples
Format a one-line XML document
A flattened document becomes a readable tree with 2-space indentation. The Try it button loads the XML and clicks Format.
Catch a mismatched tag
The port element is wrongly closed with </config> — validation names the mismatched tag. Click Try it to load the config and run Validate.
Format an RSS feed with 4-space indent
RSS feeds are XML, so they pretty-print here too. This example switches the indentation to 4 spaces.
What is XML?
XML (eXtensible Markup Language) is a text format for structured data: content wrapped in named tags, with attributes for metadata. Unlike HTML, whose tag set is fixed, XML lets you define your own vocabulary, which is why it became the default for exchanging data between systems that do not share a database.
It is still everywhere. RSS and Atom feeds, SVG graphics, your website’s sitemap.xml, Android layout files, Maven and plist configuration and countless enterprise APIs all speak XML. Machine-generated XML is usually emitted as a single dense line — valid, but painful to read or edit.
Indentation fixes that. A formatter re-inserts line breaks and leading spaces so nesting depth becomes visible at a glance: feeds become editable by hand, config files reviewable in pull requests and SVG documents navigable instead of one endless line. This tool also validates well-formedness, reporting mismatched or unclosed tags by name so you catch breakage before an XML parser does.
Because XML config files routinely contain database passwords and internal hostnames, everything here runs in your browser. Nothing you paste is uploaded or logged anywhere.
Frequently asked questions
Is my XML uploaded to a server?
No. Formatting and validation run entirely in your browser using a built-in tokenizer. You can disconnect from the internet after the page loads and everything still works — which also makes it safe to paste config files containing passwords.
What about attributes and self-closing tags?
Both are preserved exactly as written. Attributes stay attached to their element, and self-closing tags like <path d="..." /> are kept on their own line without changing nesting depth.
Does it handle RSS feeds and SVG files?
Yes. RSS, Atom, SVG and sitemaps are all XML, so they format correctly here. Declarations like <?xml ...?> and comments are also detected and left in place.
Does validation check my document against a schema (XSD or DTD)?
No — it checks well-formedness only: every tag is closed, and closing tags match their opener. Whether the elements are the right ones for your schema is a separate, structural check.
What indentation options are supported?
Two or four spaces per level, selectable before you format. Attributes and text content are never re-wrapped, so the output stays diff-friendly.