Epub to Md

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Markdown MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-markdown -- dnx GroupDocs.Markdown.Mcp --yes
Folders, licensing and more →

Use GroupDocs.Markdown to convert EPUB, MOBI, and other eBook formats to clean Markdown.

Using static method

The simplest way to convert an eBook file:

import os
from groupdocs.markdown import License, MarkdownConverter

def export_ebook_to_markdown():
    """Convert an EPUB eBook to Markdown using the static one-liner API."""

    # Step 1: Apply the license (optional for evaluation)
    if os.path.exists("GroupDocs.Markdown.lic"):
        License.set_("GroupDocs.Markdown.lic")

    # Step 2: Convert the EPUB directly to a Markdown file
    MarkdownConverter.to_file("business-plan.epub", "export-ebook-static.md")

if __name__ == "__main__":
    export_ebook_to_markdown()

business-plan.epub is sample file used in this example. Click here to download it.

![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQsAAABQCAYAAAAOa1DSAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAAEHlJREFUeJzt3XlwG9d9wPHvLhYncRIA71sUKUqULFqHbR2xlUqx3dxOk0kzzbR2/2hnOnU7STr9r800f6SdTv9Ims60406OiXPUrq1YdeLEhyzLsiRKIi1SFy/xvm+QAHED/QMSKIgADSUZ05J+n7+0j2/3Pexb/bD78N4+ZbLvVBIhhPgAGkAymSQWSxCLx3PnVECv6dB0unRSPJ4gEo3l3EVVVYwGLb2dSCSJxuIkEonsRSgKek2HTqem02LxONFo7nrpdCoG/a1lJG6UkT0GKoqCXq9Dp66WEY3FicVyl6HpVPS3lBFPJIhG4yST2ctQVQW9pqGqCpDf+dU0HXrtTs6tgkGvoSirZURjceLx7OdW2k/a77dpv4
[TRUNCATED]

Download full output

Using instance API with options

For more control, use the instance API:

import os
from groupdocs.markdown import License, MarkdownConverter, ConvertOptions, ExportImagesToFileSystemStrategy

def export_ebook_with_options():
    """Convert an EPUB eBook to Markdown using the instance API with image export and heading offset."""

    # Step 1: Apply the license (optional for evaluation)
    if os.path.exists("GroupDocs.Markdown.lic"):
        License.set_("GroupDocs.Markdown.lic")

    # Step 2: Open the eBook with a context manager
    with MarkdownConverter("business-plan.epub") as converter:
        # Step 3: Configure the image export strategy to save images to disk
        strategy = ExportImagesToFileSystemStrategy("images")
        strategy.images_relative_path = "images"

        # Step 4: Set conversion options
        options = ConvertOptions()
        options.image_export_strategy = strategy
        options.heading_level_offset = 1  # shift all headings down one level

        # Step 5: Convert and save the Markdown output
        converter.convert("export-ebook-instance.md", convert_options=options)

if __name__ == "__main__":
    export_ebook_with_options()

business-plan.epub is sample file used in this example. Click here to download it.

export-ebook-instance.md (5 KB)
images/img-001.png (4 KB)
images/img-002.jpg (35 KB)
images/img-003.png (13 KB)

Download full output

For the full list of input formats, see the supported formats page.