⌘

XML Formatter

Format xml data you provide.

0Words
0Characters
0Sentences
0mReading time
Choose a file or fill the fields, then click Run tool.

About XML Formatter

SOAP responses, RSS feeds, sitemap files and Android layout exports often come as one unbroken line of tags. Indenting them makes it far easier to find a missing closing tag or the element a bug report mentions. This is a quick reading aid for anyone who works with XML now and then.

How it works

This is a lightweight text formatter, not a full XML parser. It inserts a line break wherever one tag ends and another begins, then indents by two spaces for each level of opening tags. Closing tags step back one level. Self-closing tags, declarations like <?xml ...?> and comments do not add depth. The input is never validated, so malformed XML is still reshaped without warning. Text between tags stays on the same line as its tags. Output can be saved as formatted.xml.

How to use XML Formatter

  1. Enter the text or data in the format shown in the text box above (Paste XML).
  2. Select “Run tool” and check the result before copying or downloading it.

Worked example

Input: <note><to>Ana</to><from>Bo</from></note>. Output: <note> on the first line, <to>Ana</to> on the second line with a two-space indent, <from>Bo</from> on the third with the same indent, and </note> at the left margin on the last line. Elements that hold only text stay on one line with their opening and closing tags.

Tips for a better result

  • Element names that are one character long, such as <a> or <b>, do not add indentation, but their closing tags remove it. Expect uneven indentation after them.
  • Because nothing is validated, run your file through the XML to JSON tool if you need confirmation that it is well formed.
  • Mixed content, where text and child tags sit together, stays mostly on one line. That keeps the text readable instead of splitting sentences.

Frequently asked questions

Will it tell me if my XML is broken?

No. The formatter works on the text pattern of the tags and never parses the document. Unclosed or mismatched tags are reformatted without warning, and the indentation may drift. Use a validating tool for error checking.

Are CDATA sections and attributes preserved?

Yes. The tool only adds line breaks and leading spaces between tags. It does not rewrite tag contents, so attributes, entities and CDATA text pass through unchanged, apart from whitespace that sat directly between two tags.

Can I change the indent width?

No. Each level is indented by exactly two spaces, and there is no setting to change it. Use your editor's reindent command afterward if your project uses tabs or four spaces.

What to check

A formatted or parsed result is not proof that code is secure, correct or production-ready. Never paste production secrets.

Read the Privacy Policy for information about local processing, connected services and advertising.