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

jepub

v2.5.0

Published

Generate simple EPUB books with JavaScript.

Readme

jEpub

npm version FOSSA Status

Simple EPUB builder library, works in modern browsers.

Features

  • 📚 Create EPUB books programmatically in browsers
  • 🔧 Simple and intuitive API
  • 🏷️ Full TypeScript support with type definitions
  • 🌐 Internationalization support (21+ languages)
  • 📱 Modern ES modules and UMD builds
  • 🖼️ Image and cover support
  • 📝 HTML content with EJS templating

Demo

  1. /demo
  2. jsfiddle.net/rhov44gg

Installation

npm install --save jepub

You can also use it via a CDN:

<!-- UMD build -->
<script src="https://unpkg.com/jepub/dist/jepub.js"></script>

or:

<!-- UMD build -->
<script src="https://cdn.jsdelivr.net/npm/jepub/dist/jepub.js"></script>

For ES modules:

<!-- ES module build -->
<script type="module">
  import jEpub from 'https://unpkg.com/jepub/dist/jepub.es.js';
</script>

Dependencies

jEpub requires JSZip and EJS as external dependencies.

⚠️ Important: Starting from v2+, JSZip and EJS are not bundled with jEpub. You need to include them separately.

For UMD builds (browser usage)

Make sure these libraries are loaded before jEpub:

<!-- Required dependencies -->
<script src="https://unpkg.com/jszip/dist/jszip.min.js"></script>
<script src="https://unpkg.com/ejs/ejs.min.js"></script>

<!-- jEpub library -->
<script src="https://unpkg.com/jepub/dist/jepub.js"></script>
<script>
  const jepub = new jEpub();
  // jepub.init({
  // do something
</script>

For ES modules

You need to install dependencies separately:

npm install jepub jszip ejs
import jEpub from 'jepub';
// Dependencies will be resolved by your bundler

const jepub = new jEpub();
// jepub.init({
// do something

TypeScript Support

jEpub includes full TypeScript type definitions. No additional @types packages needed!

import jEpub, { jEpubInitDetails, jEpubGenerateType } from 'jepub';

const details: jEpubInitDetails = {
  i18n: 'en',
  title: 'My Book',
  author: 'Author Name',
  publisher: 'Publisher',
  description: '<b>Book</b> description',
  tags: ['epub', 'typescript'],
};

const jepub = new jEpub();
jepub.init(details);

// Type-safe generate method
const epub: Promise<Blob> = jepub.generate('blob');

API Reference

Constructor

const jepub = new jEpub();

Methods

init(details: jEpubInitDetails | JSZip): this

Initialize the EPUB with book details or existing JSZip instance.

interface jEpubInitDetails {
  i18n?: string; // Language code (e.g., 'en', 'fr', 'de', 'ja', 'ar' - supports 21+ languages)
  title?: string; // Book title
  author?: string; // Book author
  publisher?: string; // Book publisher
  description?: string; // Book description (supports HTML)
  tags?: string[]; // Book tags/categories
}

jepub.init({
  i18n: 'en',
  title: 'Book title',
  author: 'Book author',
  publisher: 'Book publisher',
  description: '<b>Book</b> description',
  tags: ['epub', 'tag'],
});

date(date: Date): this

Set custom publication date.

jepub.date(new Date());

uuid(id: string): this

Set custom UUID for the book.

jepub.uuid('unique-book-id');

cover(data: Blob | ArrayBuffer): this

Add cover image to the book.

// From file input
const fileInput = document.querySelector(
  'input[type="file"]'
) as HTMLInputElement;
const file = fileInput.files?.[0];
if (file) {
  jepub.cover(file);
}

// From fetch
const response = await fetch('cover.jpg');
const arrayBuffer = await response.arrayBuffer();
jepub.cover(arrayBuffer);

image(data: Blob | ArrayBuffer, name: string): this

Add an image to the book.

const response = await fetch('image.jpg');
const arrayBuffer = await response.arrayBuffer();
jepub.image(arrayBuffer, 'myImage');

Use in content: <%= image['myImage'] %>

notes(content: string): this

Add notes page to the book.

jepub.notes('<p>These are my notes...</p>');

add(title: string, content?: string | string[] | null, level?: number): this

Add a page/chapter to the book.

// HTML content
jepub.add('Chapter 1', '<p>Content...</p>');

// With images
jepub.add('Chapter 2', '<p>Image: <%= image["myImage"] %></p>');

// Array of strings
jepub.add('Chapter 3', ['Line 1', 'Line 2', 'Line 3']);

// With deep level
jepub.add('Chapter 3.1', '<p>Content...</p>', 1);

generate(type?: jEpubGenerateType, onUpdate?: jEpubUpdateCallback): Promise<Blob | ArrayBuffer | Uint8Array | Buffer>

Generate the EPUB file.

type jEpubGenerateType = 'blob' | 'arraybuffer' | 'uint8array' | 'nodebuffer';

// Generate as Blob (default)
const epub: Blob = await jepub.generate();

// Generate as ArrayBuffer
const buffer: ArrayBuffer = await jepub.generate('arraybuffer');

// With progress callback
const epub = await jepub.generate('blob', (metadata) => {
  console.log(`Progress: ${metadata.percent}% - ${metadata.currentFile}`);
});

Static Methods

jEpub.html2text(html: string, noBr?: boolean): string

Convert HTML to plain text.

const text = jEpub.html2text('<b>Bold</b> text', false);
// Returns: "Bold text"

License

ISC. Copyright 2018 lelinhtinh