EPUB FACTORY
Learn about EPUB / The basics
The basics

What's inside an EPUB file?
unzip one and look at the machinery

An EPUB file is really a ZIP. Change the extension and anyone can open it up and see. This article walks through what is actually in there when you unpack one, and what each file does. Once you know the machinery, you can guess where to look when something does not display.
In this article
  1. Unzipping an EPUB
  2. The overall shape
  3. mimetype ── the strangest file
  4. container.xml ── the signpost
  5. content.opf ── the heart of the book
  6. nav.xhtml ── the table of contents
  7. Text, CSS and images
  8. Why building one by hand is hard

Unzipping an EPUB

Start by doing it. If you have an EPUB to hand, this is all it takes.

1Copy the EPUB file (so you do not damage the original)
2Change the extension from .epub to .zip
3Unzip it as usual

That is it. No special software. An EPUB is a ZIP, so it unpacks without so much as a warning.

The reverse does not work

You might think "if it unzips, then zipping a folder and renaming it to .epub makes an EPUB". It is not that simple, because of the rules about how it must be compressed described in the next section.

The overall shape

Unpacked, it generally looks like this.

The unpacked folder
├── mimetype       marks this box as an EPUB
├── META-INF/
│  └── container.xml  signposts where the book itself is
└── OEBPS/       the folder holding the book
  ├── content.opf   book details, contents list, reading order
  ├── nav.xhtml    table of contents
  ├── text/
  │  ├── p001.xhtml  the text (one file per page)
  │  └── p002.xhtml
  ├── image/
  │  └── cover.jpg   the cover and other images
  └── style/
    └── book.css   appearance

OEBPS — that folder name, and how things are divided inside it, vary by the tool that built it. It might be item or xhtml instead, and that is fine.

What you cannot change, in name or position, is mimetype at the front and META-INF/container.xml . Those two are fixed and everything else is free — that is step one in understanding the structure.

mimetype ── the strangest file

Its contents are a single line.

application/epub+zip

Its job is to declare "this ZIP is an EPUB". But it comes with strict rules no other file has.

A reading app can decide "this is an EPUB" by reading only the first few bytes of the file. That is why the position and form are pinned down.

This is where hand-built EPUBs fall over first

Zip a folder with an ordinary compression tool and you cannot choose the file order, and mimetype gets compressed along with everything else. The result: rename it to .epub and reading apps will not open it.

Meeting the "first, uncompressed" condition means running the compression in two separate steps. That is the very first thing an EPUB-building tool does.

container.xml ── the signpost

META-INF/container.xml looks like this.

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

It does exactly one thing: it says "the book details are in OEBPS/content.opf ".

That signpost is why folder names can be free. A reading app looks at META-INF/container.xml first and goes wherever it points.

content.opf ── the heart of the book

This is the most important file in an EPUB. It splits into three parts.

PartWhat it does
metadataTitle, author, language — the book’s own details
manifestA list of every file included
spineThe order pages are turned in

metadata ── the book’s details

<metadata>
  <dc:title>Alice’s Adventures in Wonderland</dc:title>
  <dc:creator>Lewis Carroll</dc:creator>
  <dc:language>en</dc:language>
  <dc:identifier id="uid">urn:uuid:xxxxxxxx</dc:identifier>
  <meta property="dcterms:modified">2026-08-04T00:00:00Z</meta>
</metadata>

The one to watch is dc:title . What appears on the shelf in a reading app is this value, not the file name. However carefully you named the file, if this is empty the shelf shows "Untitled".

dc:language matters too. Put en for English, ja for Japanese. Without it, a reading app may not apply the typesetting rules for the language — which bites hardest in Japanese.

manifest ── the list of included files

<manifest>
  <item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
  <item id="p001" href="text/p001.xhtml" media-type="application/xhtml+xml"/>
  <item id="css" href="style/book.css" media-type="text/css"/>
  <item id="cover" href="image/cover.jpg" media-type="image/jpeg"/>
</manifest>

Every file in the EPUB has to be registered here. Add one image and forget to register it and that alone is an error. The reverse — registered but not actually there — is an error too.

The table-of-contents file is marked with properties="nav" , which is how it says "this file is the contents".

spine ── the reading order

<spine page-progression-direction="rtl">
  <itemref idref="p001"/>
  <itemref idref="p002"/>
</spine>

manifest is the list of what is inside; spine is what order it is read in. The order here becomes the page order.

And the part that matters most for a Japanese book is page-progression-direction .

ValueMeaningBooks that use it
rtlProgresses right to leftVertical text, manga
ltrProgresses left to rightHorizontal text

Leave this out of a vertically set book and pages turn the wrong way. It is one of the first things to check when vertical text is not working.

nav.xhtml ── the table of contents

EPUB 3 always requires the table of contents as its own file. It looks like an ordinary HTML list of links, distinguished by the marker epub:type="toc" .

<nav epub:type="toc">
  <ol>
    <li><a href="text/p001.xhtml">Chapter 1</a></li>
    <li><a href="text/p002.xhtml">Chapter 2</a></li>
  </ol>
</nav>

This is what comes up when a reader presses the contents button. If a linked file is missing, you have a book you cannot navigate.

You may find toc.ncx in there as well

In older EPUB 2, a file called toc.ncx did the job of the contents. EPUB 3 replaced it with nav.xhtml , but some EPUBs include both so that older reading apps still work.

Text, CSS and images

From here on it is much the same as a web page.

How you divide the text is up to you, but one file that is too large makes reading apps sluggish, so splitting by chapter is the norm.

Why building one by hand is hard

As you have seen, the structure of an EPUB is not complicated. Text, images and design instructions packed into a box with a signpost and a list — that is all.

The rules to obey, though, are finicky.

Miss one and the book fails to open, or gets bounced at store submission. And the cause of the error is usually not visible from what you see on screen.

So in real production people use a tool that assembles the structure from a manuscript or images. Even so, having looked inside once means you can guess where to look when something goes wrong — which is the point of this article.

The structure is assembled for you

EPUB FACTORY builds every part of the structure described here automatically. Just pick a folder of images or a text manuscript. No account, no installation.

Try EPUB FACTORY