XML Formatter

Format and beautify XML online with configurable spaces or tabs, readable indentation, syntax highlighting, and parsing errors. Read more

Format XML online

This XML formatter parses an XML document and adds consistent indentation so nested elements are easier to read. Choose spaces or tabs and the indentation width, then copy the formatted result from the output editor.

Formatting is intended for structured XML where whitespace between elements is used for layout. For mixed-content documents—where text and child elements appear together—review the result carefully because whitespace can be meaningful to the consuming application.

How to beautify XML

  1. Paste a complete XML document into the input editor.
  2. Select spaces or tabs and set the indentation amount.
  3. Click Format.
  4. Correct any well-formedness error, or copy the indented output when parsing succeeds.

The formatter preserves the document’s elements and attributes rather than converting XML into another data format. It does not validate the document against a DTD, XML Schema, or application-specific rules.

XML structure and well-formedness

An XML document has one document element. Start and end tag names must match, attribute values must be quoted, and reserved characters in text must be escaped where required. XML names and tag names are case-sensitive.

Namespaces distinguish names that may otherwise look identical. Formatting does not resolve or rename namespace prefixes, so declarations such as xmlns remain part of the document.

The syntax is defined by the W3C Extensible Markup Language specification.

XML formatter FAQ

Does formatting change XML data?

It changes layout whitespace. That is usually appropriate for element-only configuration data, but whitespace may matter in mixed text content or to an application with special processing rules. Test sensitive documents after formatting.

Does this format HTML?

The input must be well-formed XML. Ordinary HTML may allow syntax that an XML parser rejects; XHTML is only suitable when it follows XML rules.

How can I make XML compact?

Use the XML Minifier to remove layout whitespace. Use the XML Validator when you only need to check whether the document is well formed.

Input
Output
Settings