XML Formatter

Pretty-print and check XML in your browser with 2 spaces, 4 spaces or tab indent. Shows the parser error for malformed XML. Free.

Input
Result

About XML Formatter

The XML Formatter adds line breaks and indentation so XML is easy to read, and tells you when a document is broken. Great for API responses, SOAP messages, RSS feeds and sitemaps.

Indentation

Choose 2 spaces, 4 spaces or a tab.

Comments and CDATA kept

Comments and CDATA sections stay in the output.

Well-formed check

Broken XML shows your browser's parser message, so you can find the unclosed tag.

Mixed text

Text mixed with elements, like a paragraph with a bold word, is put on separate lines; fine for data, but check if spacing in such text matters.

Not a schema validator

It checks the XML is well-formed, not that it matches a DTD or XSD.

Private

Everything runs in your browser. Your code and data are not uploaded.

What is XML?

XML is a text format for structured data, used in feeds, sitemaps, office files, SOAP APIs and configuration. Every element must be properly opened and closed.

How to use XML Formatter

  1. Paste your XML or open a file.
  2. Choose 2 spaces, 4 spaces or Tab.
  3. Read the formatted result or the error message.
  4. Copy the output or download it.

Help & FAQ

What does the XML Formatter do?

It indents XML with two spaces, four spaces or tabs and tells you if the document is not well-formed.

Does it validate against a schema?

No. It only checks that the XML is well-formed. It does not check a DTD or XSD.

What does an error message look like?

It shows Invalid XML with your browser's parser text, for example error on line 1 at column 10: Unexpected closing tag.

Why might the message differ in another browser?

The page uses the browser's own XML parser, so the wording and detail can vary between Chrome, Firefox and Safari.

Are comments and CDATA kept?

Yes. In the test the comment and the CDATA section were kept on their own indented lines.

Does formatting change our text content?

It can. Text inside mixed content was moved onto separate lines, so do not format files where exact spacing matters.

Can it handle two root elements?

No. XML needs one root, and a document with two roots was refused with an unexpected token error.

Can we use tabs?

Yes. Choose Tab in the Indent list and nested lines start with a tab character.

Is the XML declaration kept?

Yes. The line <?xml version="1.0"?> stayed at the top of the result.

Can it fix broken XML?

No. It reports where the parser stopped, but you must fix the file yourself.

Can we open a file?

Yes. Use the Open .txt file button, or paste the text into the box.

Is our XML uploaded?

No. The formatting happens in your browser and the content is not sent to a server.

More in Developer Tools

See all 39 in Developer Tools