EPUB (Electronic Publication)
| Full name | EPUB (Electronic Publication) |
|---|---|
| Extensions | .epub |
| MIME type | application/epub+zip |
| Type | e-book, reflowable or fixed layout; ZIP container of XHTML, CSS, images, fonts, audio |
| Starts with | 50 4B 03 04 (PK\x03\x04), then mimetype at offset 30 and application/epub+zip at offset 38 |
| Specification | EPUB 3.3 (W3C Recommendation) |
| Also standardized as | ISO/IEC 23736 (EPUB 3.0.1) |
| Maintained by | W3C (Publishing Maintenance Working Group) |
| License | open, royalty-free |
EPUB is the standard format for e-books outside the Amazon ecosystem. An EPUB file is a ZIP archive that holds a small website: XHTML pages for the chapters, CSS for styling, images, fonts, a navigation document (table of contents) and a package file (OPF) that lists everything and gives the reading order. Text reflows to fit any screen size and the reader can change the font and its size.
Two versions are in use: EPUB 2 (2.0.1, XHTML 1.1, NCX table of contents) and EPUB 3 (3.0 to 3.3, HTML5 in XHTML syntax, a navigation document, fixed layout, audio/video, MathML, media overlays, better accessibility). Most reading systems support both; new books should be EPUB 3. Apple Books, Kobo, Google Play Books, Barnes & Noble and libraries (OverDrive/Libby) all sell or lend EPUB, and Kindle accepts EPUB through Send to Kindle and Kindle Direct Publishing, converting it to Amazon’s own format.
When to use EPUB#
- Use for any book or long document meant to be read on e-readers, phones and tablets: text reflows to the screen.
- Use as the master format for publishing: Apple, Kobo, Google and Amazon KDP all accept EPUB.
- Use EPUB 3 fixed layout for comics, children’s books and cookbooks where the page design must stay exact.
- Avoid when the exact print layout matters for every page (forms, papers, invoices): use PDF.
- Avoid for books sold only on old Kindle devices that need sideloaded files: those need MOBI/AZW3 (current Kindles and the Kindle apps accept EPUB through Send to Kindle).
File structure#
An EPUB is a ZIP file that follows the Open Container Format (OCF) rules:
mimetype "application/epub+zip", first entry, stored without compression
META-INF/container.xml points to the package (OPF) file
META-INF/encryption.xml optional: font obfuscation or DRM
OEBPS/content.opf package document: metadata, manifest, spine
OEBPS/nav.xhtml EPUB 3 navigation document (table of contents)
OEBPS/toc.ncx EPUB 2 table of contents (often also in EPUB 3 for old readers)
OEBPS/text/chapter1.xhtml content documents
OEBPS/styles/book.css
OEBPS/images/cover.jpg
OEBPS/fonts/serif.woff2
The folder name OEBPS is only a convention; container.xml says where the OPF file is.
The mimetype file#
The first ZIP entry must be a file named mimetype that contains exactly application/epub+zip (no newline), stored uncompressed and without an extra field. This puts the MIME type at a fixed position, so tools can identify an EPUB from its first bytes:
50 4B 03 04 0A 00 00 00 00 00 ... ZIP local file header, method 0 (stored)
... sizes, name length 8, extra length 0
6D 69 6D 65 74 79 70 65 "mimetype" at offset 30
61 70 70 6C 69 63 61 74 69 6F 6E "application/epub+zip" at offset 38
2F 65 70 75 62 2B 7A 69 70
When you build an EPUB with a command line zip tool, add mimetype first and without compression, then the rest:
zip -X0 book.epub mimetype
zip -Xr9D book.epub META-INF OEBPS
container.xml#
<?xml version="1.0" encoding="UTF-8"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
Package document (OPF)#
The package document has 3 required parts: metadata, manifest and spine. Paths in it are relative to the OPF file.
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="pub-id" xml:lang="en">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:identifier id="pub-id">urn:uuid:9e2f3c1a-4b5d-4c6e-8f70-1a2b3c4d5e6f</dc:identifier>
<dc:title>Alice's Adventures in Wonderland</dc:title>
<dc:creator>Lewis Carroll</dc:creator>
<dc:language>en</dc:language>
<meta property="dcterms:modified">2026-01-15T10:00:00Z</meta>
</metadata>
<manifest>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
<item id="cover" href="images/cover.jpg" media-type="image/jpeg" properties="cover-image"/>
<item id="css" href="styles/book.css" media-type="text/css"/>
<item id="ch1" href="text/chapter1.xhtml" media-type="application/xhtml+xml"/>
<item id="ch2" href="text/chapter2.xhtml" media-type="application/xhtml+xml"/>
</manifest>
<spine toc="ncx">
<itemref idref="ch1"/>
<itemref idref="ch2"/>
</spine>
</package>
| Element | Purpose |
|---|---|
metadata |
Dublin Core metadata. Required: dc:identifier, dc:title, dc:language; EPUB 3 also requires meta property="dcterms:modified". Optional: dc:creator, dc:publisher, dc:date, dc:description, dc:subject, dc:rights |
manifest |
every file in the publication (except mimetype, META-INF/* and the OPF itself) with an id, href and media-type. properties marks special items: nav, cover-image, scripted, svg, mathml |
spine |
the default reading order: a list of itemref that point to manifest items. linear="no" marks auxiliary content (notes, pop-ups) |
guide |
EPUB 2 only (deprecated in EPUB 3): cover, title page, start of text. EPUB 3 uses landmarks in the navigation document |
EPUB 2 uses <package version="2.0"> and marks the cover with <meta name="cover" content="cover"/> instead of properties="cover-image".
Navigation#
- EPUB 3: the navigation document is an XHTML file with
<nav epub:type="toc">that contains an ordered list (<ol>) of links. Optionalpage-list(print page numbers) andlandmarksnavs. - EPUB 2: the NCX file (
toc.ncx,application/x-dtbncx+xml) holds a tree ofnavPointelements with labels andcontent srclinks. EPUB 3 books often include an NCX too, for older reading systems.
Content documents and resources#
| Kind | EPUB 3 | EPUB 2 |
|---|---|---|
| Text | XHTML (HTML5 in XML syntax), SVG | XHTML 1.1, DTBook |
| Style | CSS (subset with -epub- prefixes for some properties) |
CSS 2 subset |
| Images | JPEG, PNG, GIF, SVG, WebP (added in 3.3) | JPEG, PNG, GIF, SVG |
| Fonts | OpenType, TrueType, WOFF, WOFF2 | OpenType |
| Audio | MP3, AAC (MP4), Opus | none |
| Scripting | JavaScript allowed in content documents, support varies | none |
Fixed-layout EPUB 3 books set <meta property="rendition:layout">pre-paginated</meta> and give each page a viewport size. Media overlays (SMIL files) synchronize text with recorded narration.
Encryption and DRM#
META-INF/encryption.xml lists encrypted resources. Its most common use is font obfuscation (the IDPF algorithm http://www.idpf.org/2008/embedding, or Adobe’s variant), which only scrambles the first bytes of embedded fonts; the book still opens everywhere. DRM systems (Adobe ADEPT, Apple FairPlay, Readium LCP, Kobo, Barnes & Noble) encrypt the content documents too; such files open only in the reader app of that store. META-INF/rights.xml often identifies the DRM scheme.
Validating and fixing EPUB files#
- Run EPUBCheck, the official validator:
java -jar epubcheck.jar book.epub. Stores reject books with EPUBCheck errors. - The most common errors:
mimetypenot first or compressed, files missing from the manifest, invalid XHTML (unclosed tags, entity without declaration), missingdcterms:modified, wrongmedia-type. - Edit an EPUB in place with Sigil or Calibre’s editor, or unzip it, fix the files, and zip it again with
mimetypefirst.
Converting#
- To Kindle: send the EPUB with Send to Kindle; Amazon converts it. For sideloading, convert to AZW3 with Calibre:
ebook-convert book.epub book.azw3. - To PDF:
ebook-convert book.epub book.pdf(Calibre) ormutool convert -o book.pdf book.epub(MuPDF). - From Markdown, Word, HTML: Pandoc creates EPUB 3:
pandoc book.md -o book.epub --metadata title="My Book".
Specifications and documentation#
- EPUB 3.3 (W3C Recommendation): the current core specification, covering the OCF container, package document, content documents and navigation
- EPUB Reading Systems 3.3: what reading software must do
- EPUB Accessibility 1.1: accessibility metadata and conformance
- EPUB 3 overview at W3C: links to all EPUB 3 specifications and notes
- Open Packaging Format (OPF) 2.0.1: the EPUB 2 package document
- EPUBCheck: official conformance checker
- EPUB on Wikipedia
Software that opens EPUB files#
| Software | Windows | macOS | Linux | Web | Can | Notes |
|---|---|---|---|---|---|---|
| SumatraPDF | ✓ | view | free, open source; unencrypted EPUB only | |||
| Apple Books | ✓ | view | built into macOS and iOS; also FairPlay DRM books from Apple. Also on iOS | |||
| Calibre | ✓ | ✓ | ✓ | view, edit, convert | free, open source e-book manager, viewer, editor and converter | |
| Thorium Reader | ✓ | ✓ | ✓ | view | free, open source; EPUB 3, accessibility, Readium LCP DRM | |
| Adobe Digital Editions | ✓ | ✓ | view | free; opens Adobe DRM library and store books | ||
| Sigil | ✓ | ✓ | ✓ | view, edit, create | free, open source EPUB editor | |
| Google Play Books | ✓ | view | upload your own EPUB files. Also on Android and iOS | |||
| Kobo apps | ✓ | ✓ | view | Kobo store books; Kobo e-readers open EPUB natively. Also on Android and iOS | ||
| Foliate | ✓ | view | free, open source | |||
| KOReader | ✓ | view | free, open source; runs on Kindle, Kobo and PocketBook e-readers. Also on Android | |||
| Moon+ Reader | view | free with paid Pro version. Also on Android | ||||
| Kindle (Send to Kindle) | ✓ | ✓ | ✓ | convert | uploads EPUB and converts it for Kindle devices and apps. Also on Android and iOS | |
| Pandoc | ✓ | ✓ | ✓ | create, convert | command line, open source; Markdown, Word, HTML to EPUB | |
| EPUBCheck | ✓ | ✓ | ✓ | view | command line validator (Java), open source |
Libraries#
Open-source libraries that read and write EPUB. See all EPUB libraries for a comparison.
| C/C++ | MuPDF |
|---|---|
| C# | QuickEPUB, VersOne.Epub |
| Java | epub4j |
| Go | go-epub, goreader/epub |
| Python | EbookLib, PyMuPDF |
| Ruby | gepub |
| Rust | epub, epub-builder |
| PHP | PHP eBook |
Related formats#
- MOBI / AZW3: Amazon Kindle formats; Calibre converts between EPUB and AZW3
- FB2: XML e-book format popular in Russia and Eastern Europe
- PDF: fixed page layout, for print-like documents
- ZIP: the container format of EPUB
- CBZ: ZIP of images for comics; EPUB fixed layout is the richer alternative