XML Formatter & Validator

Paste XML below to pretty-print, validate, or minify it. Runs entirely in your browser — nothing is uploaded.

Last updated

Formatted or minified XML will appear here.
Copied

How to format and validate XML

  1. Paste your XML.
  2. Click Format to indent it, or Minify to put it on one line.
  3. If it’s malformed, the browser’s error message is shown below; otherwise click Copy result.

About this tool

This formatter parses your XML with the browser's native DOMParser, so a malformed document — an unclosed tag, a mismatched end tag, an unescaped & — is caught the same way it would be by any standard XML parser, with the browser's own error description shown below the input. Formatting uses 2-space indentation and preserves attribute order, comments, CDATA sections, and a leading <?xml ?> declaration or <!DOCTYPE> if present; minify strips insignificant whitespace between tags to produce a single compact line.

Whitespace-only text between elements is not treated as significant, so formatting will collapse indentation-only whitespace in the source — this is safe for typical data and config XML, but not appropriate for XML where whitespace inside elements is meaningful (like <pre>-style content). External DTD and entity references are never fetched or resolved. Nothing you paste here is sent to a server — the entire tool runs as JavaScript in your browser tab.

Questions about XML

How do I check if my XML is valid?

Paste it and click Format. Unclosed or mismatched tags, an unescaped & and other errors are reported, as any standard XML parser would.

Does it keep comments and CDATA?

Yes. Comments, CDATA sections, attribute order, the XML declaration and any DOCTYPE are kept.

Does it check against a schema?

No. It checks that the XML is well-formed, not that it matches an XSD or DTD. External DTDs and entities are never fetched.

Is whitespace inside elements kept?

Spaces used only for indentation between tags are tidied up, so it suits data and config files rather than XML where whitespace has meaning.

☕ Support toolcrate