All formats

EPUB (Electronic Publication)

Full nameEPUB (Electronic Publication)
Extensions.epub
MIME typeapplication/epub+zip
Typee-book, reflowable or fixed layout; ZIP container of XHTML, CSS, images, fonts, audio
Starts with50 4B 03 04 (PK\x03\x04), then mimetype at offset 30 and application/epub+zip at offset 38
SpecificationEPUB 3.3 (W3C Recommendation)
Also standardized asISO/IEC 23736 (EPUB 3.0.1)
Maintained byW3C (Publishing Maintenance Working Group)
Licenseopen, 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#

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:

Shell
zip -X0 book.epub mimetype
zip -Xr9D book.epub META-INF OEBPS

container.xml#

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
<?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".

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#

Converting#

Specifications and documentation#

Software that opens EPUB files#

SoftwareWindowsmacOSLinuxWebCanNotes
SumatraPDF✓viewfree, open source; unencrypted EPUB only
Apple Books✓viewbuilt into macOS and iOS; also FairPlay DRM books from Apple. Also on iOS
Calibre✓✓✓view, edit, convertfree, open source e-book manager, viewer, editor and converter
Thorium Reader✓✓✓viewfree, open source; EPUB 3, accessibility, Readium LCP DRM
Adobe Digital Editions✓✓viewfree; opens Adobe DRM library and store books
Sigil✓✓✓view, edit, createfree, open source EPUB editor
Google Play Books✓viewupload your own EPUB files. Also on Android and iOS
Kobo apps✓✓viewKobo store books; Kobo e-readers open EPUB natively. Also on Android and iOS
Foliate✓viewfree, open source
KOReader✓viewfree, open source; runs on Kindle, Kobo and PocketBook e-readers. Also on Android
Moon+ Readerviewfree with paid Pro version. Also on Android
Kindle (Send to Kindle)✓✓✓convertuploads EPUB and converts it for Kindle devices and apps. Also on Android and iOS
Pandoc✓✓✓create, convertcommand line, open source; Markdown, Word, HTML to EPUB
EPUBCheck✓✓✓viewcommand 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
Javaepub4j
Gogo-epub, goreader/epub
PythonEbookLib, PyMuPDF
Rubygepub
Rustepub, epub-builder
PHPPHP eBook