File types · Explainer

The EPUB file (.epub)

An EPUB file is an e-book: a ZIP package of web pages, styles, images and a few XML files that tell a reading app what to show and in what order. This guide explains what's inside one, how the versions differ, why some EPUBs won't open, and has free sample EPUB files to download for testing.

At a glance

Full name
Electronic Publication
Extensions
.epub
MIME type
application/epub+zip
Kind
Binary: a ZIP container of XHTML, CSS, images and XML
Standard
EPUB 3.3, a W3C Recommendation; earlier versions came from the IDPF
First released
2007 (EPUB 2, IDPF), succeeding the Open eBook format of 1999
Content
XHTML, CSS and SVG; GIF, JPEG, PNG and WebP images; TrueType, OpenType and WOFF fonts; MP3, AAC and Opus audio
Layout
Reflowable (the default) or fixed layout
Opens with
Apple Books, Google Play Books, Kobo, Thorium Reader, Calibre; not browsers
Magic number
50 4B 03 04 (ZIP), then mimetype at byte 30 and application/epub+zip at byte 38

The basics

What is an EPUB file?

EPUB is the standard format for e-books. Inside, a book is a small website: each chapter is an XHTML page, styled with CSS, with images, fonts and sometimes audio, plus a package file that lists everything and sets the reading order. A reading app opens that package and lays the text out for its own screen.

Most e-book shops and libraries deliver EPUB, and Apple Books, Google Play Books, Kobo and most other reading apps read it. Publishers make EPUBs from their typesetting systems; writers often export them from Google Docs, Vellum, Scrivener, Pandoc or Calibre.

  • It reflows. A normal EPUB has no fixed pages. Change the font size or rotate your phone and the reading app lays the text out again. That's the main difference from a PDF.
  • It's an open standard. EPUB is maintained by the W3C, and anyone can create or read it without a licence.
  • It's not Amazon's format. Kindle devices use Amazon's own formats; see the comparison below.

Anatomy

What's inside an EPUB file

Rename a copy of an .epub to .zip and you can open it like any archive. Our sample-minimal.epub holds only what an EPUB 3 needs: five files. Here they are, with the bytes at the start of the file and the two XML files a reading app reads first.

sample-minimal.epub (file list, first bytes, package)
$ unzip -l sample-minimal.epub
  Length      Date    Time    Name
---------  ---------- -----   ----
       20  2026-10-27 12:00   mimetype
      252  2026-10-27 12:00   META-INF/container.xml
      673  2026-10-27 12:00   OEBPS/content.opf
      303  2026-10-27 12:00   OEBPS/nav.xhtml
      261  2026-10-27 12:00   OEBPS/text.xhtml

Bytes 0-3:    50 4B 03 04   (PK..)
Bytes 30-37:  mimetype
Bytes 38-57:  application/epub+zip

META-INF/container.xml (excerpt):
  <rootfile full-path="OEBPS/content.opf"
            media-type="application/oebps-package+xml"/>

OEBPS/content.opf:
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="id">
  <metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
    <dc:identifier id="id">urn:uuid:0b6a0c3e-1f0e-4c55-8a7e-99a0f0e0e102</dc:identifier>
    <dc:title>Minimal EPUB</dc:title>
    <dc:language>en</dc:language>
    <meta property="dcterms:modified">2026-10-27T12:00:00Z</meta>
  </metadata>
  <manifest>
    <item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
    <item id="text" href="text.xhtml" media-type="application/xhtml+xml"/>
  </manifest>
  <spine>
    <itemref idref="text"/>
  </spine>
</package>
  1. 150 4B 03 04

    The ZIP signature

    Every EPUB is a ZIP file, so it starts with the ZIP signature PK. Tools that only look at the first bytes report it as a ZIP.

  2. 2mimetype

    The mimetype file

    Must be the first file in the archive, stored without compression or an extra field, and contain exactly application/epub+zip. Because of those rules the text always sits at byte 38, where a program can find it without unzipping anything.

  3. 3META-INF/container.xml

    The container file

    The fixed starting point. Its rootfile element says where the package document is; the path OEBPS/ is only a convention.

  4. 4<package … version="3.0">

    The package document

    The .opf file describes the book. version="3.0" is used by every EPUB 3 release, including 3.3; EPUB 2 books say 2.0.

  5. 5<metadata> … </metadata>

    Metadata

    An identifier, a title and a language are required, and in EPUB 3 also dcterms:modified, the last-changed time. Authors, publisher, description, subjects, series and accessibility details are optional.

  6. 6<manifest>

    The manifest

    Every file in the book, with its media type. A listed file that's missing from the ZIP is an error.

  7. 7properties="nav"

    The navigation document

    An XHTML page with a <nav epub:type="toc"> list that reading apps use for the table of contents. Required in EPUB 3; EPUB 2 used a separate toc.ncx file instead.

  8. 8<spine>

    The spine

    The reading order: the pages a reader moves through when turning pages. Files can be in the manifest without being in the spine, such as images and stylesheets.

  9. 9OEBPS/text.xhtml

    A content document

    The book's text is ordinary XHTML: HTML written with XML rules, so every tag must be closed and the file must be well-formed.

Under the hood

How an EPUB is put together

Our sample-book.epub is a more typical book than the minimal one above. Its parts:

FileWhat it does
mimetypeIdentifies the file as an EPUB.
META-INF/container.xmlPoints to the package document.
OEBPS/content.opfThe package document: metadata, manifest and spine.
OEBPS/nav.xhtmlThe table of contents, plus landmarks such as where the main text starts.
OEBPS/toc.ncxThe EPUB 2 table of contents, kept so older reading systems can still navigate.
OEBPS/cover.xhtml, chapter-1.xhtml …The content documents, in XHTML.
OEBPS/style.cssThe stylesheet all pages share.
OEBPS/images/cover.pngThe cover, marked in the manifest with properties="cover-image" so shops and libraries show it as the thumbnail.
META-INF/encryption.xml (not in our samples)Lists encrypted or obfuscated files, used for DRM and for font obfuscation.

Why re-zipping an EPUB often breaks it

Unzip a book, edit it, and zip it again with the usual tools, and the result often fails: the mimetype file ends up compressed, gets an extra field, or isn't first. Zip it in two steps instead: zip -X0 book.epub mimetype, then zip -rX9 book.epub META-INF OEBPS. Only stored and Deflate-compressed entries are allowed.

Versions

Versions: EPUB 2, EPUB 3 and what changed

  • 1999: Open eBook (OEB). The predecessor, from the Open eBook Forum, later the International Digital Publishing Forum (IDPF).
  • 2007: EPUB 2, with a minor update, 2.0.1, approved in 2010.
  • 2011: EPUB 3.0, built on HTML5, with audio, video, scripting and better support for non-Latin scripts. A fixed-layout supplement followed in 2012 and version 3.0.1 in 2014.
  • 2017: EPUB 3.1. The IDPF merged into the W3C at the end of January 2017. Version 3.1 wasn't widely adopted and was later declared defunct.
  • 2019: EPUB 3.2, published by a W3C Community Group.
  • 2023: EPUB 3.3, the first version to become a full W3C Recommendation, on 25 May 2023. It has since been republished with corrections.
  • In progress: EPUB 3.4, a Candidate Recommendation draft at the W3C as of October 2026.
EPUB 2EPUB 3
ContentXHTML 1.1, CSS 2XHTML (HTML5), modern CSS, SVG, MathML
Table of contentstoc.ncx (an XML file from the DAISY talking-book standard)A nav element in an XHTML page; the NCX is optional, for old readers
Fixed layoutNoYes
Audio, video, scriptsNoYes, though support varies by reading app
Required metadataIdentifier, title, languageThe same, plus the dcterms:modified date

Practically every reading app made in the last decade reads both. A book made today should be EPUB 3, optionally with an NCX file, as in sample-book.epub, for the oldest devices.

Layout

Reflowable vs fixed-layout EPUB

A reflowable EPUB lets the reading app decide line breaks, pages, often the font, margins and colours too. That suits novels, non-fiction and anything mostly made of text, and it's what makes an e-book readable on a phone.

A fixed-layout EPUB sets rendition:layout to pre-paginated in the package. Each page is an XHTML document with a set size, declared in a viewport meta tag, and the reading app scales the page as a whole, like a PDF. It's used for children's picture books, comics, cookbooks and textbooks where text and pictures must stay in place. sample-fixed-layout.epub has four 600 × 800 pages.

Fixed layout is hard to read on small screens and loses most of the accessibility benefits of reflowable text, such as resizing it. Use it only when the design really depends on it.

Comparison

EPUB vs PDF, Kindle formats and HTML

EPUBPDFKindle (AZW3, KFX)HTML
LayoutReflowable or fixedFixed pagesReflowable or fixedReflowable
Open standardYes (W3C)Yes (ISO 32000)No, Amazon's ownYes
Reads well on a phoneYesOnly if made for that sizeYesYes
Opens in a browserNoYesNoYes
Single fileYesYesYesNot if it has images
Read onMost e-readers and reading apps except KindleEverythingKindle devices and appsBrowsers

Kindle e-readers don't open EPUB files directly, but Amazon's Send to Kindle service accepts EPUB and converts it for Kindle. For self-published books, Amazon's Kindle Direct Publishing also takes EPUB as an upload format. For the reverse direction, Calibre converts DRM-free Kindle files to EPUB.

Protection

DRM: why a bought EPUB may not open everywhere

The EPUB standard defines how files in the container can be encrypted, but not a DRM scheme. Shops add their own, which encrypts the content documents so only an authorised app can open them:

  • Adobe's DRM (ADEPT), used by many shops and libraries; opened with Adobe Digital Editions or a reading app that has a licence for it.
  • Apple's FairPlay, for books bought in Apple Books, which only open in Apple Books.
  • Readium LCP, a DRM with a public specification, used especially by libraries; Thorium Reader and other Readium-based apps open it.
  • Watermarking (sometimes called social DRM): no encryption, but the buyer's name or an ID is added to the book.

A DRM-protected EPUB is still a ZIP with a readable mimetype and package document, but its chapters are unreadable without the key, so other apps show an error or blank pages. Removing DRM breaks the shop's terms and is illegal in many countries. Font obfuscation, which scrambles the first bytes of an embedded font so it can't simply be copied out, is a different, much weaker mechanism and not DRM.

Troubleshooting

Why won't my EPUB open, or look right?

  • It won't open at all. The book has DRM for a different app, the download was cut off (a damaged ZIP), or it's a Kindle file renamed to .epub. Check the first bytes: an EPUB starts with PK and has application/epub+zip at byte 38.
  • A shop or library rejects it. Most run EPUBCheck. Fix every error it reports; common ones are a compressed or misplaced mimetype, files missing from the manifest, invalid XHTML and a missing dcterms:modified.
  • My fonts or margins are ignored. Reading apps let the reader choose fonts, sizes and themes, and override publisher CSS to do it. Some need a setting such as "publisher defaults" to use the book's fonts.
  • The cover doesn't show. In EPUB 3 the cover image needs properties="cover-image" in the manifest; older apps also look for <meta name="cover">. Both are in sample-book.epub.
  • Images are missing. The image isn't in the manifest, or the path's capitalisation differs: paths inside an EPUB are case-sensitive.
  • It looks different in every app. Reading systems support CSS to very different degrees. Keep styling simple and test in more than one app.

How to

How to open, create, edit and convert an EPUB

  • Read it: Apple Books on iPhone, iPad and Mac; Google Play Books (upload it to your library) on Android, iPhone and the web; Kobo e-readers and apps; Thorium Reader and Calibre on Windows, macOS and Linux. Browsers don't display EPUB files, so a link to one downloads it.
  • On a Kindle: send it with Amazon's Send to Kindle, by email, app or web page, and it arrives converted.
  • Create it: in Google Docs, File, Download, EPUB; with a writing tool such as Vellum or Scrivener; or convert with Pandoc: pandoc book.md -o book.epub (Pandoc also reads DOCX).
  • Edit it: Sigil and Calibre's editor open the package and let you edit the XHTML, CSS and metadata directly.
  • Convert it: Calibre's ebook-convert book.epub book.pdf (or .azw3, .docx). Conversion to PDF fixes the layout for one page size.
  • Validate it: java -jar epubcheck.jar book.epub with EPUBCheck, the reference checker that shops and libraries use. All our samples pass EPUBCheck 5.4.0 with no errors or warnings.

Security

Is it safe to open an EPUB file?

An EPUB is web content in a ZIP file, so it shares the risks of both:

  • Scripts. EPUB 3 allows JavaScript. The specification asks reading systems to run it in a restricted context, and many don't run scripts at all. A reading app with a bug in that restriction is the main way a malicious book could do harm.
  • XML tricks. The standard forbids external entities and XInclude, which closes off XML attacks such as XXE, but only if the reading app's XML parser enforces it.
  • ZIP tricks. Like any archive, an EPUB can contain path-traversal file names or decompress to an enormous size. Software that unpacks uploaded EPUBs on a server should reject both.
  • Remote resources. Audio, video, fonts and script data may be loaded from the internet, which tells that server when and where the book is opened.

Get e-books from shops, libraries and authors you trust, keep reading apps updated, and run EPUBCheck before accepting EPUB uploads on a website.

Free downloads

Sample EPUB files to download

Free sample EPUB files for testing reading apps, converters, upload pipelines and validators. Every one passes EPUBCheck 5.4.0 (and 5.2.1) with no errors or warnings.

sample-book.epub · 51.6 KBDownload

Browsers can't show this kind of file in a page. Download it to open it in the app it belongs to.

What's inside sample-book.epub

Browsers can't display EPUB, so there's no live preview here. Open sample-book.epub in a reading app to see the book, or rename a copy to .zip to find these parts.

  1. Metadata

    Title, author (the fictional Ada Example), language, publisher, date, subject, description, rights and the dcterms:modified time in OEBPS/content.opf.

  2. Accessibility metadata

    schema:accessMode, accessibilityFeature, accessibilityHazard and an accessibilitySummary, the information shops and libraries show for accessible books.

  3. A cover

    An 800 × 1200 PNG marked as cover-image, the <meta name="cover"> fallback for older apps, and a cover page as the first item in the spine.

  4. Two tables of contents

    An EPUB 3 navigation document with a nested entry and hidden landmarks, and a toc.ncx for EPUB 2 reading systems.

  5. Chapter 2: images, tables and a footnote

    A PNG figure with alt text and a caption, a table with a caption and header cells, and a footnote marked with epub:type="noteref" and footnote, which many apps show as a pop-up.

  6. Chapter 3: languages and direction

    Paragraphs in Dutch, French, German, Japanese and right-to-left Arabic, each with its own lang and xml:lang.

  7. Stored and compressed entries

    The mimetype file and the PNG images are stored uncompressed; the XHTML, CSS and XML files are Deflate-compressed.

All sample EPUB files

  • Sample EPUB 3 book

    sample-book.epub · 51.6 KB (52,807 bytes)

    A three-chapter reflowable EPUB 3 with a cover, a navigation document and an NCX, a stylesheet, an image, a table, a footnote, several languages and accessibility metadata.

    • Testing reading apps, previews and converters
    • Learning the structure of an EPUB
  • Minimal EPUB 3

    sample-minimal.epub · 1.5 KB (1,528 bytes)

    Only the five files an EPUB 3 needs: mimetype, container.xml, the package document, a navigation document and one page. It's the file shown in the anatomy above.

    • Parser tests: don't assume a cover, CSS or NCX
    • A starting template
  • EPUB 2.0.1 book

    sample-epub2.epub · 23.3 KB (23,845 bytes)

    An EPUB 2 with XHTML 1.1 pages, an OPF 2.0 package, an NCX table of contents, a guide and a cover.

    • Testing support for older books
    • Checking version detection
  • Fixed-layout EPUB

    sample-fixed-layout.epub · 34.0 KB (34,771 bytes)

    Four pre-paginated 600 × 800 pages, each an image with text over it, with left and right page-spread hints.

    • Testing fixed-layout rendering
    • Checking thumbnails for picture books
  • 1 MB EPUB file

    sample-1mb.epub · 1 MB (1,048,576 bytes)

    A 40-chapter reflowable book, padded to exactly 1,048,576 bytes (1 MiB) with a text chunk in its stored cover PNG.

    • Upload limits at exactly 1 MiB
    • Reading-app and converter performance

Ways to test with them

  • Upload limits: sample-1mb.epub is exactly 1,048,576 bytes, so you can test a 1 MiB limit at the boundary.
  • File type detection: all five start with 50 4B 03 04. A detector that reports application/zip instead of application/epub+zip isn't checking the mimetype file at byte 30.
  • Repackaging: unzip sample-book.epub, zip it again with your tool, and run EPUBCheck on the result. A mimetype error means the tool doesn't write EPUB-safe archives.
  • Version handling: open sample-epub2.epub and sample-book.epub in the same app; both should show a table of contents and a cover.
  • Fixed layout: sample-fixed-layout.epub should show whole pages that scale with the window, not text that reflows.

Free to use for testing, teaching and demos, commercially or not, with no attribution needed. A link back to this page is always appreciated.

Put it online

Have an EPUB file? Give it a link.

Drop an EPUB on 99helpers and it gets its own link, for a free book, a review copy or a sample chapter. Browsers can't display EPUB files, so visitors download it and open it in their reading app.

Questions

EPUB files, frequently asked

What is an EPUB file?

An e-book in the open EPUB format: a ZIP package of XHTML pages, CSS, images and XML files that describe the book. Most e-readers and reading apps open it.

How do I open an EPUB file?

Use Apple Books on Apple devices, Google Play Books on Android, a Kobo e-reader, or Thorium Reader or Calibre on a computer. Browsers can't display EPUB files directly.

Can I read an EPUB on a Kindle?

Not by copying it across, but Amazon's Send to Kindle service accepts EPUB files and converts them. Books with DRM from other shops won't convert.

What's the difference between EPUB and PDF?

An EPUB reflows to fit any screen and lets you change the text size; a PDF has fixed pages that look the same everywhere. EPUB is better for reading on phones, PDF for printing.

What's the difference between EPUB 2 and EPUB 3?

EPUB 3 is based on HTML5 and adds fixed layout, audio, video, scripting and better language support, and replaces the NCX table of contents with an XHTML navigation document. Reading apps today read both.

Is an EPUB just a ZIP file?

Yes, with rules: a mimetype file must come first, uncompressed, and the package must follow the EPUB specification. Rename a copy to .zip to look inside.

How do I convert an EPUB to PDF?

Use Calibre: open the book and choose Convert books, or run ebook-convert book.epub book.pdf. Books with DRM can't be converted.

How do I check that an EPUB is valid?

Run EPUBCheck, the reference validator: java -jar epubcheck.jar book.epub. Shops and libraries use it and reject books with errors.

Related formats

Other file types explained

Keep going

Related

Sources

Last reviewed 27 October 2026.