npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mark-epub-down

v0.3.0

Published

EPUB-to-Markdown CLI and Node.js package for LLM knowledge bases, wikis, and ingestion workflows

Readme

mark-epub-down

npm version Node.js CI License: MIT

EPUB-to-Markdown CLI and Node.js package for LLM knowledge bases, wikis, and related ingestion workflows.

Why

This project focuses on producing semantically useful Markdown from EPUB input. The v1 goal is not visual EPUB reproduction. It prioritizes source order, document structure, TOC preservation, and conservative transformation rules.

The target output is text-first Markdown for LLM knowledge bases, wikis, and related ingestion workflows. In many current ingestion setups, preserving raw image assets or Markdown image links does not reliably produce usable downstream image understanding, while it does add complexity and processing cost. For that reason, v1 keeps image extraction opt-in instead of making it part of the default output path.

What v1 Does

  • converts one EPUB into one Markdown file
  • preserves spine order and source heading structure
  • emits a dedicated ## TOC section from EPUB-native TOC data
  • includes minimal OPF-derived YAML front matter
  • rewrites internal targets conservatively for merged single-file output
  • can optionally extract internal images into co-located or split per-output asset directories and emit Markdown image links

What v1 Does Not Do

  • visually reproduce EPUB layout or CSS
  • guess missing structure aggressively
  • optimize first for reader-specific Markdown rendering
  • split output by chapter in the v1 baseline

Requirements

  • Node.js 20, 22, or 24
  • npm

Install

Install the CLI globally:

npm install -g mark-epub-down

Or add the package to a Node.js project:

npm install mark-epub-down

The GitHub repository also includes Claude Code skill and subagent definitions plus a Codex skill source. These are documented separately in docs/agent-skills.md and are not part of the published npm package.

CLI Usage

Convert an EPUB:

epub2llm input.epub

Write to an explicit output path:

epub2llm input.epub -o output.md

Extract internal images into a co-located asset directory:

epub2llm input.epub --extract-images

Extract internal images into split sources/ and assets/ roots:

epub2llm input.epub --extract-images --output-layout=split --split-root raw

Run without global install:

npx --package mark-epub-down epub2llm input.epub

Show CLI help:

epub2llm --help

Existing output files are never overwritten silently. In an interactive terminal session, the CLI may ask for explicit overwrite confirmation with a default No answer.

When image extraction is enabled, the tool treats the Markdown file and asset directory as one logical output set for overwrite checks.

--output-layout only applies when image extraction is enabled. It does not change the Markdown-only default output path.

When --output-layout=split is used, --split-root sets the sibling sources/ and assets/ roots. If you use -o instead, the output path must live under a sources/ directory so the matching asset namespace can be mirrored under assets/.

Node API

The published package currently exposes a CommonJS API:

const { convertEpub } = require("mark-epub-down");

(async () => {
  const result = await convertEpub({
    inputPath: "input.epub",
    outputPath: "output.md",
    extractImages: "all",
  });

  console.log(result.outputPath);
  console.log(result.assetOutputPath);
  console.log(result.warnings);
})();

Split layout is also available through the Node API:

(async () => {
  await convertEpub({
    inputPath: "input.epub",
    extractImages: "all",
    outputLayout: "split",
    splitRootDir: "raw",
  });
})();

If the output path already exists, convertEpub() throws unless overwrite: true is passed:

(async () => {
  await convertEpub({
    inputPath: "input.epub",
    outputPath: "output.md",
    overwrite: true,
  });
})();

Output Shape

The generated Markdown follows this high-level structure:

---
title: Example Book
creator: Example Author
language: en
published: 2026-04-09
---

# Example Book

## TOC

- [Chapter 1](#...)
- Chapter 2

## Chapter 1

...

With optional image extraction enabled, the output set becomes:

output.md
output.assets/

Markdown image links are written relative to output.md.

With split layout enabled, the output set becomes:

raw/
  sources/
    output.md
  assets/
    output/

Nested subpaths under sources/ are mirrored under assets/, and Markdown image links are written relative to the final Markdown file location.

In split layout, these image links use standard relative filesystem paths from the final Markdown file to the mirrored asset namespace. Some Markdown tools may impose their own preview or workspace-root restrictions on multi-level ../ image paths; that tool-specific behavior is outside this project's output contract.

Docs

Limitations

  • Fixed Layout EPUB (FXL) is out of scope for the v1 baseline
  • some internal links or TOC targets may degrade to plain text when they cannot be rewritten safely
  • complex tables may remain as HTML instead of being flattened into incorrect Markdown
  • images are removed by default in v1 as a deliberate text-first ingestion boundary; optional image extraction currently targets internal raster image resources, including common SVG-wrapped cover or full-page image cases
  • audio, video, CSS background images, and general vector SVG output are not part of the current v1 image-extraction path
  • output files are never overwritten silently; interactive terminal use may ask for explicit confirmation

Roadmap

  • expand real-world sample coverage for malformed or inconsistent EPUB inputs
  • refine deeper footnote and note-topology edge cases beyond explicit source anchors
  • refine richer table fallback boundaries for more complex publisher markup

Development

npm install
npm run build
npm run typecheck
npm test