Zokilos

XML Formatter & Validator

Validate well-formedness and pretty-print XML

What Is This XML Formatter & Validator?

A tool that checks whether your XML is well-formed using the browser's own native XML parser, then re-indents valid XML for readability — not a regex guess, a real parse.

How to Validate and Format XML

1

Paste your XML.

2

Pick an indentation style.

3

Click Validate & Format, then copy the result.

Well-Formed vs Valid: What Gets Checked

Well-formed means the syntax itself is correct — every tag properly closed and nested, attributes quoted, one root element. Valid goes further, checking conformance against a specific schema (XSD or DTD) that defines exactly which elements and attributes are allowed. This tool checks well-formedness only.

Understanding Validation Errors

When the XML isn't well-formed, the status badge shows the browser parser's own error message — the same kind of message you'd get from any standards-compliant XML parser, describing exactly what broke and roughly where.

Indentation Options

Choose 2 spaces, 4 spaces, or a tab character for the re-formatted output. Switching the option after formatting re-runs it automatically.

What Gets Preserved: Comments, CDATA, and Processing Instructions

Comments, <![CDATA[...]]> sections, processing instructions like the <?xml version="1.0"?> declaration, and DOCTYPE declarations are all kept exactly as written, not reformatted or altered internally.

Important: Mixed Content and Whitespace

For XML where text and child elements sit together in the same parent (mixed content, like a sentence with a bolded word in the middle), reformatting adds whitespace and line breaks around those child elements — which becomes part of the surrounding text. If whatever reads this XML treats text content literally without trimming, that extra whitespace changes what it sees. Purely structural XML (elements containing only other elements, no inline text) isn't affected.

Does This Validate Against an XSD or DTD?

No. Schema validation checks that your XML follows a specific set of rules about allowed elements, attributes, and structure — a separate, more specific check than well-formedness. This tool doesn't accept or check against an XSD or DTD file.

What This Tool Doesn't Do

  • No XSD or DTD schema validation
  • No XPath querying or XML transformation (XSLT)
  • No safeguard against whitespace changes in mixed-content XML

Limitations

  • Well-formedness only, not schema validation
  • Reformatting mixed-content XML can alter text node whitespace
  • No XPath, XSLT, or namespace-aware tooling

Benefits of Using This Tool

  • Real validation using the browser's native XML parser
  • Preserves comments, CDATA, and processing instructions untouched
  • Choice of 2-space, 4-space, or tab indentation
  • Runs entirely in your browser — nothing uploaded to a server
  • Free, with no sign-up required

Frequently Asked Questions

Does this validate against an XSD or DTD schema?

No. It only checks well-formedness — correct XML syntax, like matched tags and proper nesting — not validity against a specific schema. A file can be perfectly well-formed and still violate a schema's rules about what elements or attributes are allowed.

What's the difference between well-formed and valid XML?

Well-formed means the XML syntax itself is correct: every tag is properly closed and nested, attributes are quoted, and so on. Valid means it also conforms to a specific schema (XSD or DTD) that defines which elements, attributes, and structures are allowed. This tool checks the former, not the latter.

Can reformatting change my actual data?

For XML with mixed content — text and child elements together in the same parent, like a sentence with a bolded word in the middle — yes, potentially. The formatter adds whitespace and line breaks around child elements, which becomes part of the surrounding text nodes. If your XML consumer reads text content literally without trimming, that extra whitespace changes what it sees. Purely structural XML (elements containing only other elements, no mixed text) isn't affected.

What does it preserve untouched?

Comments, CDATA sections, processing instructions (like the XML declaration), and DOCTYPE declarations are all kept exactly as written, not reformatted or re-indented internally.

Is this real validation, or just a formatting guess?

Real validation. It uses the browser's own native XML parser (DOMParser) to actually parse the document, so a genuine syntax error is reported, not guessed at with a regex.

Is my XML sent to a server when I use this?

No. Validation and formatting both happen entirely in your browser. Nothing you paste here is uploaded anywhere.