ZapKit

XML Formatter & Validator

Indent XML so its structure is readable, check that it's well-formed, or minify it to save space, all in your browser.

What is an XML formatter?

XML is a markup format for structured data, used in RSS feeds, sitemaps, SOAP APIs, Android layouts, Office files, SVG images and countless configuration files. Generated XML often arrives with no line breaks, which makes it nearly impossible to read or debug.

An XML formatter, sometimes called a beautifier or pretty printer, indents each nested element on its own line. This one also validates: if the document isn't well-formed you get the parser's error instead of output, so it doubles as a quick checker. Minifying does the opposite, removing indentation to reduce size before sending or storing XML.

How to use the XML Formatter

  1. 1.Paste the XML

    A config file, an API response, a feed or a sitemap.

  2. 2.Format or minify

    Choose the indent, or collapse the document onto one line.

  3. 3.Fix any errors

    If the XML is broken, the parser's message says what's wrong instead.

Example: a one-line book catalogue

A catalog element holding two books, each with an id, title, author, price and, for the second, an empty tags element:

Elements
10
Indent
2 spaces per level
<title>Clean Code</title>
kept on one line
<tags></tags>
written as <tags/>

Ten elements on one line become a readable tree with each book's details indented under it.

Checked by a real XML parser

The browser's XML parser reads the document strictly, so unclosed tags, mismatched names, unescaped & characters and missing quotes are caught. The output is rebuilt from the parsed tree, which means it's guaranteed to be well-formed.

Elements that contain only text stay on one line, empty elements are written as self-closing tags, and comments, CDATA sections and processing instructions are kept. Formatting trims the whitespace around text; for mixed content like XHTML paragraphs, check that spacing still reads correctly.

Frequently asked questions

What does well-formed XML mean?

Every tag is closed and properly nested, there's one root element, attributes are quoted and special characters are escaped.

Does it validate against an XSD or DTD?

No. It checks that the XML is well-formed, not that it follows a particular schema.

Is the XML declaration kept?

Yes. A leading <?xml version="1.0"?> line is kept at the top.

Can it format SVG files?

Yes. SVG is XML, so paste the file's code to tidy or minify it.

More Developer tools