Free online tools

XML Formatter

Make compact XML easier to inspect. Choose an indentation style and keep meaningful text and markup together inside mixed-content elements.

Enter your values

Paste a well-formed XML document with one root element.

This tool processes your input in your browser.

Result

Indent the markup between elements

Paste a complete XML document. The formatter checks it with the browser’s XML parser and adds indentation around nested structure. Original element prefixes, attribute quotes, comments, and entity spellings remain in the copied text.

Keep meaningful spacing in text

Text alongside child elements can depend on its spacing. A paragraph such as “Check the green label” stays together even when “green” is wrapped in another element. Elements with inline spacing, CDATA or xml:space="preserve" keep their original contents.

Frequently asked questions

Why is part of the document kept on one line?

An inline run of text and elements is kept together to avoid adding spaces to the text it represents. Element-only sections can be indented.

What should I do if validation fails?

Check that tags close in the correct order, every attribute value is quoted, and ampersands and angle brackets in text use an appropriate XML reference.

What kind of XML is supported?

Use one well-formed document with its data embedded directly. Documents that require a DTD, stylesheet or schema processing instruction, or XML inclusion are outside this formatter’s scope.