⚡
usefultools.dev
XML

XML Formatter & Validator – Pretty Print XML

NEW

XML formatter that pretty-prints or minifies XML and validates it, showing the line and column of any error. Keeps CDATA, comments and PIs. Free, in-browser.

Runs 100% in your browser — your input is never uploaded or stored on our servers.

⚡

Quick Examples

Typical inputs and the results this tool produces.

Pretty
<a><b/></a>
<a> <b/> </a>
Minify
<a> <b>1</b> </a>
<a><b>1</b></a>
No comments
<!-- x --><a/>
<a/>
Error
<a><b></a>
Line 1, column 7: Mismatched closing tag </a>…
Error
<a x=1/>
Line 1, column 6: Value of attribute 'x' must be quoted
📖

Overview

This XML formatter indents a document so its structure is easy to read, or minifies it into a single line by dropping whitespace between elements. At the same time it checks that the XML is well-formed and tells you exactly where it breaks: a mismatched closing tag, an unquoted attribute, a bare & or a second root element.

Developers paste SOAP responses, RSS and sitemap files, Android layouts, Maven POMs or product feeds to inspect them. CDATA sections, comments, processing instructions and the XML declaration are kept, text-only elements stay on one line, and elements with mixed text or xml:space="preserve" are left untouched so meaningful whitespace survives.

Validation runs twice in your browser: a strict built-in parser gives precise line and column numbers, and the browser’s own XML parser double-checks namespaces. Nothing is uploaded.

Why use this tool?

  • Pretty print and validate XML in one step
  • Exact line and column for every syntax error
  • Keeps CDATA, comments and processing instructions
  • Minify feeds and payloads for transport
  • Runs locally, your XML stays private
⭐

Features

🌳

Pretty print

Indents nested elements with 2 spaces, 4 spaces or tabs.

🗜️

Minify

Removes whitespace between elements and, optionally, all comments.

✅

Well-formedness check

Catches mismatched or unclosed tags, unquoted attributes, duplicate attributes, bad entities and extra root elements.

📍

Line and column

Every error message points to the exact position in your input.

🧾

Lossless details

CDATA, comments, processing instructions, DOCTYPE and mixed content are preserved.

💾

Copy or download

Copy the output or save it as an .xml file.

🛠️

How to Use

1

Paste XML

Paste your document into the XML input box or press Sample.

2

Choose the mode

Pick Pretty print or Minify, then the indent and comment options.

3

Fix any errors

If the XML is invalid, the red message shows the line and column to fix.

4

Copy the result

Press Copy or Download to use the formatted XML.

🤔

Frequently Asked Questions