Skip to content
AgileLogics

XML Editor

Write and edit XML with syntax highlighting, right in your browser.

Loading editor…

What this XML editor does

XML (Extensible Markup Language) is a text format for structured data that uses nested, named tags. It's behind sitemaps, RSS and Atom feeds, SOAP web services, SVG images, Maven and Android project files, and the insides of .docx and .xlsx documents. This editor lets you open, change and save XML in the browser with syntax highlighting.

Type an opening tag such as <price> and the matching </price> appears automatically. Long documents are easier to handle with the fold arrows in the gutter, which collapse any element down to a single line. Find / Replace, Word Wrap, Dark Theme, Full Screen, Copy and Download (the file saves as data.xml) are on the toolbar.

What it won't do: check well-formedness, validate against a schema, or pretty-print. The editor colors whatever you type, valid or not. "Checking your XML" below covers the tools for that.

Sample document

This catalog shows the main pieces of XML syntax in one place: the declaration, a namespace prefix, a comment, attributes, an escaped ampersand, a character reference and a CDATA section.

<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns:media="http://example.com/ns/media">
  <!-- Prices are in EUR -->
  <book id="bk101" lang="en">
    <title>XML &amp; You</title>
    <author>Gambardella, Matthew</author>
    <price currency="EUR">44.95</price>
    <media:cover src="covers/bk101.jpg"/>
  </book>
  <book id="bk102" lang="fr">
    <title>Le Petit Prince</title>
    <author>Saint-Exup&#233;ry, Antoine de</author>
    <price currency="EUR">9.50</price>
    <summary><![CDATA[Use <b> tags freely in here & nothing breaks.]]></summary>
  </book>
</catalog>

It parses cleanly, and &#233; comes out as "é" in the second author's name.

Well-formedness rules from the XML 1.0 spec

Every XML parser must stop at the first well-formedness error, so one small slip makes the whole file unreadable. The rules below are from the W3C XML 1.0 (Fifth Edition) recommendation.

Rule Broken Fixed
Exactly one root element <a/><b/> <root><a/><b/></root>
Tags are case-sensitive and must nest properly <Item><b></Item></b> <item><b></b></item>
Attribute values are always quoted <book id=bk101> <book id="bk101">
Ampersands and less-than signs in text must be escaped <t>Tom & Jerry</t> <t>Tom &amp; Jerry</t>
The declaration comes first, with nothing before it a blank line, then <?xml ...?> <?xml ...?> on line 1

XML predefines only five entities: &amp;, &lt;, &gt;, &quot; and &apos;. HTML names like &nbsp; or &copy; are errors unless a DTD declares them; use numeric references such as &#160; instead. Namespace prefixes like media: must be declared with an xmlns: attribute, as required by Namespaces in XML 1.0.

Checking your XML

  1. Click Download. The file saves as data.xml; rename it if you like.
  2. Drag the file into Chrome, Firefox or Edge. A well-formed file shows as a document tree; a broken one shows the parser's error with a line and column.
  3. On the command line, xmllint --noout data.xml (part of libxml2; preinstalled on macOS, and in the libxml2-utils package on Debian and Ubuntu) prints nothing when the file is well-formed and lists errors when it isn't.

The XML formatter also reports parse errors when you paste XML into it and gives you an indented copy to read.

Related editors

The same editor exists for HTML, which looks similar but follows far more forgiving parsing rules, and for JSON and YAML if you're converting a data format away from XML. All of them are listed on the online code editors page.

Last updated

Frequently asked questions

Does the XML editor check whether my document is well-formed?
No. It highlights tags, attributes, comments and CDATA but doesn't parse or validate the document, so an unclosed tag or a bare & isn't flagged. Open the downloaded file in a browser, which shows a parse error with a line number if the XML is broken, or run xmllint --noout file.xml.
Can it validate XML against an XSD schema or DTD?
No. Schema validation needs a validating parser and the schema file. xmllint --schema schema.xsd file.xml does it from the command line, and most IDEs with XML support can validate against an XSD as well.
Is there a Format or pretty-print button?
Not in the XML editor; the Format button only appears in the JSON editor. To re-indent minified XML, use the XML formatter tool, but read its notes first: it drops the XML declaration and CDATA sections, and doesn't re-escape & in text.
Can I edit sitemaps, RSS feeds, SVG or Android layouts here?
Yes. They're all XML, so any of them can be edited and highlighted. The editor doesn't know their specific vocabularies, so it won't suggest element names or check that a sitemap follows the sitemaps.org protocol.
Is my XML stored or uploaded?
No. It stays in your browser tab and is cleared when you reload or close the page. Copy or download it to keep it.