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

book2text

v1.0.1

Published

Convert ePub and MOBI files to text-based formats (JSON, Markdown, plain text)

Readme

book2text

A command-line tool to convert e-books (ePub, MOBI, and PDF) to text-based formats (JSON, Markdown, plain text). If the files are copy proected, this script will fail.

Features

  • Convert e-books to structured JSON
  • Convert e-books to readable Markdown
  • Extract raw text content without formatting
  • Extract metadata, table of contents, and chapter content
  • Simple command-line interface

Installation

Global Installation (Recommended for CLI usage)

# Install globally
npm install -g book2text

# Verify installation
book2text --help

This allows you to run book2text from anywhere in your terminal.

Local Installation

# Install locally in your project
npm install book2text

# Run using npx
npx book2text --input book.epub

Usage

Command Line

book2text --input <file-path> [options]

Options:

  • --input, -i: Path to the input ePub, MOBI, or PDF file (required)
  • --format, -f: Output format: "json", "markdown", or "text" (default: "markdown")
  • --output, -o: Output directory or file path (default: "./converted/")
  • --clean, -c: Clean the output directory before conversion (default: false)
  • --no-metadata: Exclude metadata from the output (default: include metadata)
  • --no-toc: Exclude table of contents from the output (default: include TOC)
  • --heading-level: Base heading level for markdown output: 1-6 (default: 1)
  • --css: Custom CSS to include in markdown output (default: none)
  • --help, -h: Show help

Examples

Basic Usage

# Simple conversion (defaults to markdown format)
book2text -i book.epub

# Convert to JSON format
book2text -i book.epub -f json

# Convert to plain text
book2text -i book.epub -f text

Output Customization

# Custom output path
book2text -i book.epub -o ./my-output/book.md

# Clean output directory first
book2text -i book.epub -c

# Exclude metadata and table of contents
book2text -i book.epub --no-metadata --no-toc

# Customize heading levels (start at H2 instead of H1)
book2text -i book.epub --heading-level=2

# Add custom CSS (for Markdown output)
book2text -i book.epub --css="body { font-family: Arial; max-width: 800px; margin: 0 auto; }"

JavaScript API

const { convertEbook } = require("book2text");

const run = async () => {
  // Basic conversion
  const result = await convertEbook({
    input: "./my-book.epub",
    outputFormat: "markdown", // default
    outputPath: "./output/",
  });

  // Advanced options
  const resultWithOptions = await convertEbook({
    input: "./my-book.epub",
    outputFormat: "json",
    outputPath: "./output/",
    cleanOutput: true,
    includeMetadata: false,
    includeToc: false,
    headingLevel: 2,
    customCss: "body { font-family: Arial; }",
  });

  if (result.success) {
    console.log(`Converted to: ${result.outputFile}`);
  } else {
    console.error(`Error: ${result.error}`);
  }
};

run();

Supported Formats

Input Formats:

  • ePub (.epub)
  • MOBI (.mobi) - limited support, best to convert to ePub first
  • PDF (.pdf)

Output Formats:

  • JSON (.json) - structured output with metadata, TOC, and content
  • Markdown (.md) - formatted text with headings, links, and styling
  • Plain Text (.txt) - raw text without formatting

License

MIT