developerFree

XML Formatter

Pretty-print XML input.

Free — no signupYour input stays on this device for this operation.Learn how to use XML Formatter →
XML Formatter illustration
ResultLive

01 Overview

About XML Formatter

XML Formatter takes dense or single-line XML — from APIs, SOAP services, RSS feeds, sitemaps or config files — and rewrites it with consistent indentation, so elements, attributes and text content form a clear tree you can follow. Formatting changes only whitespace and line breaks; it does not rename elements, alter attributes or change text values, so the document carries exactly the same information. If the XML will not format, it is usually not well-formed — a missing closing tag or an unescaped character. It runs entirely in your browser.

Adjust the options and review your result before downloading.
See our privacy policy for input handling and usage information.
Use a modern browser. Availability and performance depend on your device and the selected tool.

02 Workflow

How to use XML Formatter

  1. 1
    Paste your XMLAdd the document with its root element, and check the tags look balanced before formatting.
  2. 2
    Run the formatterThe XML is rewritten locally with consistent indentation for each nesting level.
  3. 3
    Read the treeUse the indentation to follow parent and child elements. If an error appears, note the position, fix the structure and format again.
  4. 4
    Copy the formatted XMLPaste it into your editor, documentation or support ticket — and edit an element or attribute in the output first if you need to test a change.

03 Good to know

Frequently Asked Questions

What does an XML formatter change?

Only whitespace: indentation and line breaks between elements. Element names, attributes and text content stay exactly as they were in the original document.

Can I format XML with a declaration and comments?

Yes. The XML declaration at the top of a document and comments inside it are preserved by formatting; only their placement and indentation are tidied up.

What if my XML will not format?

That usually means the XML is not well-formed — for example, a missing closing tag or an unescaped special character. Fix the reported problem and format again.

What is the difference between XML and HTML?

XML is a strict data format with custom tags for exchanging structured information, and its parsers reject any syntax error. HTML is a markup language for web pages, and browsers are forgiving of its mistakes. That strictness is why XML must be well-formed before it can be used.

Can I format an RSS feed or a sitemap?

Yes. Both are XML documents, so formatting them makes their structure readable: the feed items or the listed URLs become easy to follow as a tree, which helps when you are debugging a feed or checking a sitemap.

Does formatting change the XML declaration?

No. The declaration at the top of the document, and any comments inside it, are preserved by formatting. Only their placement and indentation are tidied up, so the document carries exactly the same information.

Why does formatting fail on my XML?

That usually means the XML is not well-formed, for example a missing closing tag or an unescaped special character such as a bare ampersand. Fix the reported problem and format again.