XML Formatter

Prettify and validate XML documents with customizable indentation and element spacing.

XML Formatter Runs locally · No sign-up
Output

About XML Formatter

XML from feeds, legacy systems, and config exports arrives as one long line more often than not, which makes it nearly impossible to inspect the document tree. This formatter parses the markup and rewrites it with indentation that reflects the nesting, so parent and child elements become obvious at a glance.

The tool builds a full parse tree before touching the output, which is why malformed input is flagged with a clear error instead of producing garbage. Indentation width, tabs versus spaces, and whether attributes should each sit on their own line are all configurable, while namespaces, comments, and CDATA sections pass through untouched.

Developers integrating with legacy SOAP services use it to read responses, QA engineers inspect exported configs before comparing versions, and content teams tidy up RSS or sitemap feeds before publishing. It is equally handy for validating that a freshly generated document is well-formed before it goes to a strict consumer.

How to Use

  1. Paste your XML.
  2. Press Format to add indentation.
  3. Fix any reported parse errors, then copy the output.

Example

<root><item>1</item><item>2</item></root> <root> <item>1</item> <item>2</item> </root>

Formatting indents child elements under their parents, making the document hierarchy obvious.

FAQ

Can it format XML with namespaces?

Yes, namespace declarations are preserved and formatted like any other attribute.

Does it validate well-formedness?

Yes, malformed tags, mismatched nesting, and illegal characters are reported so you can fix them.

Can I choose the indentation size?

Yes, use 2, 4 spaces, or tabs to match your project's convention.

Can it format XML with attributes on separate lines?

Yes. An option places each attribute on its own indented line, which is handy for wide documents with long attribute lists, such as SVG or XSLT files, where wrapping keeps things readable.

Does formatting work on XML fragments?

Yes. A fragment without a single root element is still indented based on nesting, and the parse-error report will tell you if the fragment itself is malformed.