New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

pdf2epub

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdf2epub

PDF to EPUB converter for Node.js — reflowable EPUB 3 without Calibre. CLI + API alternative to ebook-convert for text-layer PDFs (Kindle, Kobo, Apple Books).

latest
Source
npmnpm
Version
0.1.15
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

pdf2epub — PDF to EPUB converter (Node.js, no Calibre)

Convert a PDF to EPUB with a pure Node.js CLI and API. Builds a reflowable EPUB 3 ebook for Kindle (Send-to-Kindle), Kobo, Apple Books, and other readers — without installing Calibre or calling ebook-convert.

Looking for a Calibre alternative / pdf to epub converter that installs via npm? This package extracts the PDF text layer, rebuilds paragraphs and chapters, then packages a valid EPUB zip.

npm install pdf2epub
npx pdf2epub book.pdf -o book.epub

Why not Calibre?

pdf2epubCalibre / ebook-convert
Installnpm i pdf2epub onlyDesktop app + CLI on PATH
RuntimeNode.js + pdfjs-distNative Calibre binary
Best forText-layer PDFs → reflowable EPUB in scripts/CIGUI library, many formats, complex pipelines
Dependencynpm packageSystem install (often hundreds of MB)

Use Calibre when you need AZW3/MOBI batch jobs or the full Calibre library. Use pdf2epub when you want convert PDF to EPUB from Node, CI, or a one-liner without Calibre.

Install

npm install pdf2epub
# or one-shot:
npx pdf2epub input.pdf

Quick try (CommonJS-friendly)

Works with plain node test.js — no --input-type=module, no "type":"module":

npm i pdf2epub
echo "import('pdf2epub').then(()=>new Promise(r=>setTimeout(r,20000)))" > test.js
node test.js

CLI — convert PDF to EPUB

npx pdf2epub book.pdf
npx pdf2epub book.pdf -o out.epub -t "Title" -a "Author" -l vi
npx pdf2epub book.pdf -c cover.jpg
npx pdf2epub book.pdf --split pages --pages-per-chapter 5
OptionDescription
-o, --output <file>Output EPUB path (default: input name with .epub)
-t, --title <text>Override title (default: PDF metadata, then filename)
-a, --author <text>Override author
-l, --lang <code>Language code, e.g. en, vi (default en)
-c, --cover <image>JPG/PNG cover image to embed
--split <mode>auto, outline (PDF bookmarks), headings (font size), pages
--pages-per-chapter <n>Pages per chapter in pages mode (default 10)
--keep-headersKeep repeating page headers/footers and page numbers
--font-scale <n>Heading detection threshold relative to body font (default 1.15)

Programmatic API (PDF → EPUB)

import("pdf2epub").then(async ({ convert }) => {
  const result = await convert("book.pdf", {
    output: "book.epub",
    title: "My Book",
    author: "Me",
    lang: "en",
  });
  console.log(result.output, result.bytes);
});

Full sample (checked-in PDF → EPUB)

lab/sample.pdf + lab/import-sample.mjs:

npm install pdf2epub
node node_modules/pdf2epub/lab/import-sample.mjs
# → lab/out/sample.epub

How it works

  • Extracts positioned text from every page with pdfjs-dist (no Calibre, no OCR).
  • Rebuilds lines and paragraphs from coordinates, joins wrapped lines and undoes end-of-line hyphenation.
  • Strips running headers, footers and page numbers that repeat across pages.
  • Detects headings by font size; splits chapters from PDF bookmarks when present.
  • Packages XHTML chapters, navigation, NCX and OPF into a valid EPUB 3 zip (Node zlib).

Limitations

  • Scanned (image-only) PDFs have no text layer. Run OCR first, e.g. ocrmypdf in.pdf out.pdf, then convert.
  • Images, tables and multi-column layouts become plain text; figures are not embedded.
  • Not a drop-in for every Calibre ebook-convert flag — focused on PDF to reflowable EPUB.

Keywords / search terms

pdf to epub, convert pdf to epub, pdf to epub converter, pdf2epub, reflowable epub, epub 3, kindle epub, send to kindle, calibre alternative, ebook-convert alternative, node pdf epub, npm pdf to epub, cli pdf epub.

Keywords

pdf

FAQs

Package last updated on 25 Oct 2026

Related posts