XML Formatter

Beautify or minify XML and catch mismatched tags.

Minified XML from an API or an export is close to unreadable. This tool indents it properly, or squeezes it onto a single line, and checks along the way that every tag closes in the right order. If something's wrong it tells you which tag is the problem. Attributes, comments, CDATA sections and processing instructions are all handled.

How to use it

  1. Paste your XML.
  2. Choose beautify or minify.
  3. Pick the indent size.
  4. Copy the result, or read the error if the XML isn't well formed.

When it helps

  • Reading XML returned by an API.
  • Hunting for a mismatched tag in a config file.
  • Shrinking an XML document.
  • Normalising two files before comparing them.

Good to know

  • Short text elements are kept on one line so the output doesn't balloon.
  • The error message names the tag it expected, which usually points straight at the typo.
  • Only whitespace between tags changes; your data stays as it was.

What well-formed means

XML must have exactly one root element, every opening tag needs a matching closing tag in the right order, attribute values need quotes, and special characters in text must be escaped. This tool checks the tag structure while it formats and tells you where the first problem is.

It doesn't validate against a schema, which would check that the right elements appear in the right places.

Worked example: a feed

Paste a minified RSS or sitemap file and choose Beautify, and each element lands on its own line with consistent indentation, so you can scan it. Choose Minify to remove whitespace and shrink the file for transfer.

Because short text elements stay on one line, a title element reads like <title>Tools</title> rather than being split across three lines.

XML versus JSON

XML is older, more verbose and supports attributes, namespaces and mixed content, which suit documents. JSON is lighter and fits data. Many APIs have moved to JSON, but XML remains common in feeds, office file formats, configuration, sitemaps and enterprise systems.

If you need to move between them, format first, then convert with the tool that suits your data.

Common XML errors

The usual errors are an unclosed tag, tags closed in the wrong order, an unescaped ampersand or less-than sign in text, attribute values without quotes, and more than one root element. The formatter reports the first tag-level problem it finds.

Escape special characters as entities, such as &amp; for an ampersand, or wrap text in a CDATA section.

Encoding declarations

The first line of an XML file often declares its encoding, such as UTF-8. If special characters look wrong after formatting, check that the declaration matches how the file was saved.

Questions

Does it validate against a schema?

No, only that tags are balanced and the document is well formed.

Is there a size limit?

Whatever your browser can hold in memory.