XML Formatter & Validator

Pretty-print XML with exact validation: mismatched tags, unquoted attributes and unclosed comments are reported with line/column positions.

Developer Tools Runs in your browser · no upload

Reviewed 17 November 2026 · Free · No account needed

ExecutionYour browserInput never leaves your tab
File retentionNoneNothing is stored
AccountNot requiredNo sign-up, no paywall
PriceFreeNo trial, no usage cap on the tool itself

How to use

  1. Paste XML or choose an .xml file.
  2. Pick the indentation and press Format & validate.
  3. Read the formatted result, or fix the reported line/column error.

Example

Input: <root><a x='1'>short</a></root>

Output: formatted with 2-space indent + 'Well-formed' confirmation

How it works

The XML is parsed and re-printed with consistent indentation. Malformed XML reports the parser's error instead of a formatted result.

A dependency-free tokenizer validates well-formedness first — matched open/close tags, quoted attributes, closed comments — then re-prints the tree at your chosen indent (2 spaces, 4 spaces or tab). Attributes are normalised to double quotes, and a text-only element shorter than 80 characters prints inline on one line.

Worked example

<root><a x='1'>short</a></root> formats with 2-space indent, reports Well-formed, and the attribute becomes x="1".

Edge cases to know

  • Errors carry the position: mismatched tags, unquoted attributes and unclosed comments are reported with line and column.
  • Well-formedness only — no DTD or XSD schema validation.
  • Whitespace-only text between elements is collapsed away.
  • Comments, doctypes, processing instructions and CDATA sections are preserved as written.

Limits & compatibility

  • Checks well-formedness only — no DTD/XSD schema validation.
  • Attribute quoting is normalised to double quotes; entity references are preserved as written.
  • Whitespace-only text between elements is collapsed away.

Privacy

Tokenised and formatted locally in your browser. Nothing is uploaded or stored.

Related tools

FAQ

Questions about XML Formatter & Validator

What counts as validation here?

Well-formedness only — the tokenizer checks that every tag closes correctly, attribute values are quoted, comments and CDATA sections are terminated, and reports mismatches with line and column positions. It does not validate against a DTD or XSD schema, so an element the schema forbids will still format happily.

What indentation options does the formatter offer?

Two spaces, four spaces or a tab. Elements with short text content stay on one line — <a x="1">short</a> does not explode across three lines — while longer content and nested structures indent normally. Whitespace-only text between elements is collapsed away, which is what makes the output stable across runs.

Does formatting alter attributes or entity references?

Attribute quoting is normalised to double quotes — x='1' becomes x="1" — but entity references are preserved exactly as written rather than decoded or re-encoded. Attribute order is kept as in the source. You can paste XML or choose an .xml file, and everything is tokenised locally with no upload.