XML to Markdown Converter
Paste XML or upload an .xml file. Each element becomes a heading, with its attributes listed and its text kept.
Markdown output will appear here...
To convert XML to Markdown, paste the XML (or upload an .xml file) into the box above and copy the Markdown on the right. The root element becomes a # heading and each child goes one level deeper. Attributes are listed under their element as - **name:** `value`, and the element's text follows as a paragraph.
What does the output look like?
Attributes and text
<book id="bk101" lang="en">
<title>XML Developer's Guide</title>
<price currency="USD">44.95</price>
</book># <book>
- **id:** `bk101`
- **lang:** `en`
## <title>
XML Developer's Guide
## <price>
- **currency:** `USD`
44.95Repeated elements
<order id="7">
<item sku="A1">Coffee</item>
<item sku="B2">Tea</item>
</order># <order>
- **id:** `7`
## <item>
- **sku:** `A1`
Coffee
## <item>
- **sku:** `B2`
TeaMixed text and inline elements
<p>Hello <b>world</b> again</p># <p>
Hello again
## <b>
worldText directly inside an element is joined and placed before its children, so the sentence order is lost. This converter is built for data, not for marked-up prose.
An RSS item with a CDATA description
<rss version="2.0"><channel><item><title>Post</title><description><![CDATA[<p>Hello & welcome</p>]]></description></item></channel></rss># <rss>
- **version:** `2.0`
## <channel>
### <item>
#### <title>
Post
#### <description>
<p>Hello & welcome</p>CDATA text is kept unescaped. The & needs no entity, and the <p> stays as raw HTML.
How are XML attributes shown?
As a bullet list right under the element's heading, one line per attribute, with the value in inline code so IDs and URLs are not reformatted. They keep the order they have in the tag. Namespace declarations such as xmlns:dc="..." count as attributes and are listed too, and prefixed names like dc:creator keep their prefix.
What happens to repeated elements?
Each one gets its own heading at the same level, in document order, as with the two <item> elements above. They are not merged into a table. If the XML is really a list of records and you want a table, export it as CSV and use CSV to Markdown, or rebuild it in the Table Generator.
Why does it say the XML is invalid?
The browser's XML parser is strict, unlike its HTML parser. A bare & (write &), a tag that is never closed, mismatched case such as <Item>...</item>, or two root elements side by side all stop the conversion. The message after "Invalid XML:" is the start of the parser's own error, which usually names the line.
Can Pandoc convert XML to Markdown?
Only for XML formats it knows, such as DocBook and JATS: pandoc -f docbook book.xml -t gfm. For those, Pandoc is the better tool because it understands sections, lists and emphasis. For arbitrary XML (a config file, an API response, a feed) it has no reader, which is the case this page covers. For JSON payloads, use JSON to Markdown.
How are CDATA, namespaces, entities and other edge cases handled?
| Input | What you get |
|---|---|
| CDATA sections | Kept as text, exactly as written; HTML inside stays as raw HTML |
| Comments, processing instructions, <?xml ?> declaration | Left out |
| Entities (& < é) | Decoded to & < é |
| Empty or self-closing element (<debug/>) | A heading with nothing under it |
| Whitespace and indentation between tags | Ignored; text is trimmed |
| Text mixed with child elements | Text joined and placed before the children |
| Namespaced names (dc:creator) | Prefix kept; xmlns declarations listed as attributes |
| Element names in headings | Written as # <name> with literal angle brackets. Renderers that allow raw HTML may treat <name> as a tag and hide it |
| Backtick in an attribute value | Breaks the inline code span around the value |
| More than six levels of nesting | Headings stop at ###### |
| Accents, CJK and emoji | Passed through unchanged |
How does this compare with Pandoc and XSLT?
| MDConvert (this page) | Pandoc | XSLT (e.g. xsltproc) | |
|---|---|---|---|
| Reads any XML | Yes | No, only formats it knows (DocBook, JATS and others) | Yes |
| Output shape | Fixed: a heading per element | Real prose Markdown | Whatever your stylesheet writes |
| Setup | None, runs in the browser | Install Pandoc | Install a processor and write a stylesheet |
| Batch / scripting | No, one file at a time | Yes | Yes |
| Your data leaves your machine | No | No | No |
For a repeatable conversion with a specific layout, an XSLT stylesheet is the better tool. This page is for reading or documenting an XML file without writing one.
Maintained by Ankit Aglawe. Last updated .
Related Tools
Need a different format? See every tool on the Markdown converter page, or go back to the MDConvert home page.