100% Local · Free · No Sign-up

Convert XHTML & EPUB Chapters to Markdown

Convert xhtml to md for EPUB chapters, DocBook and Javadoc output, and CMS exports that never left the 2000s. The document is parsed with the browser’s own HTML parser — so a malformed file is recovered rather than rejected — then DOMPurify strips the presentational and executable layer and Turndown maps what remains onto CommonMark and GFM, entirely in your browser.
Drop your XHTML file here to convert to MarkdownDrag & drop files here, or click anywhere to browse · .xhtml, .html

Processing happens 100% in your browser — nothing is uploaded.

100% Local Processing — Your files never leave your device

How to convert XHTML to Markdown

  1. Provide the document: drop an .xhtml or .html file onto the dropzone, or paste the markup into the editor. For an EPUB, rename it to .zip, unzip it, and use the chapter files inside.
  2. Local processing: the markup is parsed, sanitised with DOMPurify and converted by Turndown in a Web Worker — no upload and no asset fetching.
  3. Copy or download: copy the Markdown or save it as a .md file for your docs-as-code pipeline, Hugo/Jekyll content directory or vault.

Why Convert XHTML to Markdown with MD Convert?

  • Lenient parsing where a strict XML parser fails

    Real XHTML routinely breaks the rules it declares: an unescaped &, an unclosed <p>, a stray attribute. A conforming XML parser must reject the whole document for any one of them. Parsing through the browser's HTML parser recovers the document instead, which is what you want for a file you did not write a decade ago. Self-closing <br />, <img /> and <hr /> are handled natively.

  • Presentational debt removed, not translated

    style attributes and <style> elements are stripped, along with <form>, <input> and <button>, and <font>, <center> and bare <span class> wrappers leave no trace — there is no Markdown construct for them. That removal is the point of the conversion rather than a loss of fidelity.

  • Structural semantics mapped precisely

    Headings become ATX (# … ######), <strong> and <b> become **bold**, <em> and <i> become _italic_, lists keep their nesting, <pre> becomes a fenced block rather than an indented one, and tables become GFM pipe tables whose first row is treated as the header — a pipe table without a delimiter row is not a table at all in GFM.

  • Sanitisation as a security control

    Inherited markup is treated as hostile input: <script> elements, on* event-handler attributes and javascript: URLs are removed before conversion, so nothing executable reaches the preview pane or survives into the Markdown you paste elsewhere. That matters most for exactly these files — old pages of unknown provenance.

XHTML to Markdown: Before and After

Self-closing void elements are handled natively, and the presentational layer — `xmlns`, `style`, `<span class>`, `<font>` — is dropped rather than translated. Structural semantics survive: the heading, the emphasis and the code element all map onto CommonMark.

Input · XHTML
<div xmlns="http://www.w3.org/1999/xhtml">
  <h2 style="color:#c00">Configuration</h2>
  <p>Set <code>retries</code> to <em>3</em>.<br />
  Restart required.</p>
  <img src="diagram.png" alt="Retry flow" />
</div>
Output · Markdown
## Configuration

Set `retries` to _3_.  
Restart required.

![Retry flow](diagram.png)

Understanding the XHTML Format: XHTML 1.1 (W3C Recommendation)

Format
Extensible HyperText Markup Language
Media type
application/xhtml+xml

Technical Specifications & XHTML Recovery Rules

  • Lenient Error-Tolerant Parsing: Uses the browser's native DOM parser rather than a rigid XML parser; recovers unclosed tags, unescaped ampersands (`&`), and legacy syntax errors without throwing fatal XML validation halts.
  • EPUB Chapter Extraction: Directly converts `.xhtml` chapter payloads extracted from unzipped EPUB archives (`OEBPS/` or `EPUB/` directories) into clean, standalone Markdown files.
  • Presentational Tag & Style Stripping: Completely removes legacy 2000s formatting clutter—including `<font>`, `<center>`, inline `style` attributes, and arbitrary `<span class>` wrappers—while preserving text and semantic hierarchy.
  • Namespace & Self-Closing Handling: Strips XML namespace declarations (`xmlns`) cleanly; self-closing void elements (`<br />`, `<hr />`, `<img />`) resolve natively without pre-processing.
  • Legacy Chrome & Nav Trimming: Javadoc, Doxygen, and DocBook generated headers, footers, and navigation frames are preserved as markup text unless scoped to the primary content container.

Developer Alternative: CLI (Pandoc EPUB) & Python (BeautifulSoup) Extraction

For batch EPUB archives or server-side pipelines, Pandoc and BeautifulSoup with markdownify produce the same kind of Markdown outside the browser.

Bash (Pandoc EPUB)
# Convert an entire EPUB archive directly to GFM with media extraction
pandoc -f epub -t gfm book.epub -o book.md --extract-media=./media

# Or convert a single unzipped XHTML chapter
pandoc -f html -t gfm chapter01.xhtml -o chapter01.md
Python (BeautifulSoup)
# Programmatic XHTML conversion with lenient error recovery
# requires: pip install beautifulsoup4 markdownify
from bs4 import BeautifulSoup
from markdownify import markdownify as md

with open("chapter.xhtml", "r", encoding="utf-8") as f:
    # html.parser recovers malformed legacy XML without throwing fatal XML errors
    soup = BeautifulSoup(f.read(), "html.parser")

markdown_text = md(str(soup), heading_style="ATX")
print(markdown_text)

How You Can Verify the Privacy Claim

Browser-only

Zero server upload

Conversion runs inside your browser tab. Open DevTools, switch to the Network panel, and convert a file: for every format except URL to Markdown you will see no request carrying your document — because there is no endpoint to send it to.

In your tab

Parses on the main thread

Parsing stays inside your browser tab — this format’s parser needs DOM APIs. Nothing is uploaded. Everything is plain JavaScript — no native plugin, no WebAssembly toolchain, nothing to install.

No account

Nothing to sign up for

No login, no quota, no paywall, and no tracking tied to your files. Analytics are cookieless and aggregate only. Read the privacy policy for the full data-flow breakdown, including the one proxied exception.

The parsers doing the work

No proprietary black box: each format is handled by a widely audited open-source library, running client-side at the version pinned in our lockfile.

XHTML to Markdown — FAQ

Can I convert EPUB chapters with this?

Yes. An EPUB is a ZIP archive whose content documents are XHTML by specification, so rename the .epub to .zip, unzip it, and convert the chapter files inside OEBPS/ or EPUB/ — one chapter to one Markdown file. That is the practical route for re-editing or republishing a book you own.

Is XHTML parsed strictly as XML?

No, deliberately. Parsing goes through the browser's HTML parser, which recovers from well-formedness errors instead of rejecting the document the way a conforming XML parser must. The trade-off is that you will not be told about a namespace or well-formedness problem — you get a converted document rather than an error.

What happens to inline CSS, MathML and SVG?

Inline CSS is discarded, since colour, font and alignment have no Markdown equivalent. Embedded MathML and SVG are removed with their text content kept, because neither has a CommonMark representation. If a formula matters, extract it to LaTeX before converting.

Why does my Javadoc or DocBook output start with a navigation list?

Because generated documentation wraps every page in header, footer and sidebar markup, and all of it is real content to a converter. Trim the source to the content element — usually a single <div> — before converting. That one step is the difference between a clean result and ten minutes of editing.