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 🙏

© 2025 – Pkg Stats / Ryan Hefner

split-epub

v0.0.3

Published

CLI tool to split an EPUB file into multiple pages based on selected patterns

Readme

EPUB Splitter CLI

A CLI tool to split XHTML files inside an EPUB into separate "pages" using a marker (e.g., <div ... class="stl_ stl_02" ...>). Fast, interactive, and ready for npx!

Getting your EPUB from PDF

This tool is designed to split EPUBs generated from PDFs using PDF24 Tools. The resulting EPUB will usually contain all content in a single page—perfect for splitting with this CLI.

Note: The table of contents (TOC) will not be generated automatically. After splitting, you should manually create or edit the TOC using Sigil, a free EPUB editor.


Features

  • 📖 Split EPUB XHTML/HTML files into individual pages
  • 🔍 Choose your own marker (text/regex)
  • 🗂️ Automatically updates OPF manifest and spine
  • 🚀 Interactive interface powered by @clack/prompts
  • ⚡ No install required—just use npx
  • 🟢 Bun/Node.js compatible

Installation

Using npx (recommended)

No installation required! Just run:

npx split-epub@latest

Global installation

npm install -g split-epub@latest

Then run:

split-epub

Prerequisites

  • Node.js 18+ or Bun
  • An EPUB file in your working directory

Usage

Simply run:

npx split-epub

The CLI will guide you through:

  1. Selecting the EPUB file to split
  2. Choosing the marker (text/regex)
  3. Naming the output file
  4. Optionally previewing the split files (without repackaging)

What does it do?

  • Unzips the EPUB into a temporary folder
  • Finds all XHTML/HTML files and splits their content using your marker
  • Creates new .xhtml files for each fragment
  • Updates the OPF manifest and spine
  • Repackages everything into a new EPUB

Precautions

  • Make a backup of your original EPUB before running the script
  • The script tries to update the .opf if found. If your EPUB uses a different manifest/table of contents system, review manually
  • If your marker is different (spaces, single quotes, extra attributes), adjust the marker option or the regex in the code

Limitations

  • Does not handle advanced TOC (nav.xhtml): you may need to review and regenerate navigation for perfect results
  • If your XHTML files use unusual namespaces or structures, you may need to adjust the script

Development

Local development

  1. Clone the repository:
git clone https://github.com/adcuelloa/split-epub.git
cd split-epub
  1. Install dependencies:
bun install
  1. Run in development mode:
bun run index.ts
  1. Build for production:
bun run build

Project structure

.
├── index.ts             # Main CLI application
├── types.ts             # TypeScript interfaces
├── package.json         # Dependencies and scripts
├── tsconfig.json        # TypeScript configuration
├── README.md            # This file
└── global.d.ts          # Global TypeScript definitions

License

MIT

Author

Created by adcuelloa


Built with ❤️ using @clack/prompts