📖
ebook-rs v0.19.0
⚡ Pure Rust 2024 • AI RAG & MCP • Python / WASM / C FFI • 30 In / 27 Out Formats

High-Performance Engine for 30 Input & 27 Output Formats

Pure Rust engine for EPUB 2/3, KFX, MOBI, AZW3, FB2, KEPUB, LIT, CBZ, PDF, DOCX, ODT, RTF, PPTX, LaTeX, Typst, AsciiDoc, Org, reST, PDB, PMLZ, RB, TCR, HTMLZ, TXTZ, OEB, ZIP, HTML, TXT, and Markdown with Native AI RAG Chunking, MCP Server, Python/WASM/C FFI, and Readium APIs.

Add to Cargo.toml Try Live Reader Demo
EPUB 2/3
AZW3/MOBI
FB2
CBZ
PDF
ODT
Markdown/TXT
samples/Alice in Wonderland - Lewis Carroll EPUB2.epub

Chapter I: Down the Rabbit-Hole

Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, 'and what is the use of a book,' thought Alice 'without pictures or conversations?'

So she was considering in her own mind whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.

Built for Performance & Parity

Designed to deliver 100% feature parity with epub.js and foliate-js in native Rust and WebAssembly.

⚡

0-Allocation Full-Text Search

Pre-computed lowercase section caches allow searching millions of characters in under 1 millisecond.

📚

30-Input / 27-Output Pure-Rust Engine

Bidirectional parsers & exporters for EPUB 2/3, KFX, MOBI, AZW3, FB2, KEPUB, DOCX, ODT, RTF, PDF, PPTX, TeX, Typst, AsciiDoc, Org, reST, PDB, PMLZ, RB, TCR, HTMLZ, TXTZ, OEB, ZIP, HTML, TXT, and Markdown.

📍

Complete IDPF CFI Engine

Canonical Fragment Identifier parsing, range calculations, and character position ordering.

🔒

IDPF & Adobe Font De-Obfuscation

Native SHA-1 key calculation and XOR byte transformations for protected font files.

🌐

WebAssembly & Reader Server

Supports `wasm-bindgen` for browser web apps and includes a built-in multithreaded HTTP reader server.

🖼️

Automatic Base64 Inlining

Inlines CSS stylesheets and images into self-contained HTML strings without external blob URIs.

Simple & Intuitive API

Load any eBook format with auto-detection in 2 lines of code.

Basic Usage
Full-Text Search
WASM Bindings
use ebook_rs::Book;

fn main() -> Result<(), String> {
    // Auto-detects EPUB, MOBI, AZW3, FB2, KEPUB, or LIT from path
    let mut book = Book::from_file("alice.azw3")?;

    println!("Title: {}", book.metadata().title);
    println!("Total Sections: {}", book.spine().len());

    // Search full-text across chapters
    let matches = book.search("Rabbit");
    println!("Found {} search matches", matches.len());

    Ok(())
}