Developer Cheat Sheet

XML Syntax Cheat Sheet

Published September 8, 2026

The core rules that make XML well-formed. For how XML compares to JSON, see What Is XML?.

Rule Detail
One root element Every XML document must have exactly one top-level element containing everything else
Tags must be closed Every opening tag needs a matching closing tag, or a self-closing tag like <br/>
Proper nesting Tags must close in the reverse order they opened
Case-sensitive tags <Item> and <item> are treated as different tags
Quoted attribute values Attribute values must be wrapped in quotes, like id=”42″

Use the XML Formatter & Validator

The XML Formatter & Validator formats and validates XML instantly.

Try it yourself

XML Formatter & Validator

Try our XML Formatter & Validator →

Frequently Asked Questions

Does XML need a declaration line?

A declaration like is recommended and often expected, though not every parser strictly requires it.

Can XML have multiple root elements?

No. A well-formed XML document must have exactly one root element that contains all the other elements.

Explore More

Find the right tool, or browse Brekzy's other resources.