⌘K

Data Formats

XML

XML (Extensible Markup Language) is a text format that describes data using nested, self-labelled tags, designed for documents and long-lived system-to-system messaging.

Updated 12 Aug 2026

How XML represents data

XML wraps every value in a named tag. Because tags nest, a document forms a tree, and because each tag is self-describing, an XML file explains its own structure to a reader who has never seen it before. Elements can also carry attributes, which is how XML distinguishes metadata from content — something JSON has no direct equivalent for.

XML predates JSON by roughly a decade and grew up around publishing and enterprise integration. That heritage shows: namespaces prevent tag collisions when documents from different vendors are merged, XSD schemas define strict contracts, XSLT transforms one document shape into another, and XPath queries deep into a tree.

Where XML is still the right choice

  • Office documents — DOCX, XLSX and PPTX are ZIP archives full of XML
  • SVG vector graphics and RSS/Atom feeds
  • SOAP web services and banking or healthcare message standards
  • Android layouts, Maven builds and many configuration ecosystems

XML compared with JSON

AspectXMLJSON
Payload sizeLarger — closing tags repeat every nameSmaller
AttributesYesNo, everything is a property
CommentsYesNo
Mixed contentText and elements can interleaveNot supported
Typical useDocuments, enterprise messagingWeb APIs, config

JSON Formatter

The JSON Formatter converts between JSON, XML, CSV and YAML in the browser.

Try JSON Formatter

Characteristics

  • Every element has an opening and closing tag, or is self-closing
  • Elements may carry attributes as well as child content
  • Namespaces allow vocabularies to be mixed safely
  • Strict well-formedness rules — one root element, correct nesting, escaped entities

Common uses

  • Office file formats and publishing pipelines
  • SVG graphics and RSS feeds
  • SOAP APIs and regulated industry message standards
  • Configuration in Java, Android and .NET ecosystems

Advantages

  • Self-describing and readable without external documentation
  • Mature validation, transformation and query languages (XSD, XSLT, XPath)
  • Supports comments, attributes and mixed content
  • Namespaces make merging vocabularies safe

Limitations

  • Noticeably more verbose than JSON for the same data
  • Parsing is slower and more memory-hungry
  • Entity expansion features have caused real security vulnerabilities
  • Awkward to map onto native language data structures

Examples

The JSON example above, expressed as XML with an attribute
<user id="4821">
  <name>Ada Lovelace</name>
  <active>true</active>
  <roles>
    <role>admin</role>
    <role>editor</role>
  </roles>
</user>

Frequently asked questions

What is XML used for?

Documents, feeds, office file formats and system-to-system messaging where strict contracts and rich metadata matter.

Is XML still relevant?

Yes. It underpins DOCX, SVG, RSS and many regulated messaging standards, even though JSON dominates new web APIs.

What is the difference between XML and HTML?

HTML has a fixed vocabulary for describing web pages; XML lets you define your own tags for any kind of data.

Can XML be converted to JSON?

Yes, though attributes and mixed content have no direct JSON equivalent and need a convention.

Is XML harder to read than JSON?

For simple records JSON is terser, but XML is often clearer for document-shaped content with markup inside text.

Related terms

All terms

Related tools

Related guides

All guides