File format

EPUB - Electronic Publication

EPUB is the open ebook standard behind almost every bookshop, library and reading app outside Amazon, and it is the format most books arrive in when they are not Kindle files.

An EPUB file is an electronic book. The name is short for Electronic Publication, and the format was published by the International Digital Publishing Forum, a publishing industry group that developed it from the earlier Open eBook standard and later folded into the World Wide Web Consortium. Today EPUB is what almost every bookshop, library lending service and reading app outside Amazon hands you. Its defining feature is reflowable text: the book has no fixed pages, so your reading app decides where each page ends, based on the screen you are holding and the font size you picked.

How an EPUB file is built

An EPUB is a ZIP archive with rules about what goes in it. Rename one to .zip and any unzip tool will open it. The first entry has to be a small file called mimetype, stored without compression, holding the text application/epub+zip. Next to it, META-INF/container.xml points at the package document, an XML file that usually ends in .opf. That package document is the plan of the archive: a manifest listing every file in the book, and a spine giving the order they are read in.

The chapters themselves are ordinary web pages, written in XHTML and styled with CSS, with images, fonts and audio sitting alongside them as separate files. EPUB 3, the current generation, is built on HTML5. ZIP compression is lossless, so packing the book up degrades nothing, but the pictures inside keep whatever compression they already had, so a JPEG cover is still lossy. Most EPUBs reflow; a fixed-layout EPUB pins content to a page size instead, which is how comics and illustrated children's books are made. Some shops wrap the book in DRM, which encrypts the chapter files and leaves a reader without a licence able to see little more than the metadata.

What metadata an EPUB carries

The package document opens with a metadata section, and it uses Dublin Core, a small vocabulary of general description fields shared across libraries and archives. A report shows them with their dc: prefix: dc:title, dc:creator for the author, dc:contributor for editors, translators and often the software that produced the file, dc:language, dc:publisher, dc:date, dc:subject for keywords and categories, dc:description for the blurb, and dc:rights. One more, dc:identifier, is the book's unique id and is usually an ISBN or a generated UUID.

EPUB 3 adds a required dcterms:modified timestamp recording when the file was last changed, plus refinements that say how a name should be sorted and what role a person played. Conversion tools write their own entries on top: files that have been through Calibre typically carry calibre:series, calibre:series_index, calibre:title_sort, calibre:timestamp and calibre:rating.

Several of those fields are personal. Author and contributor names are there by design, and the contributor line frequently names the exact program and version used. The modification timestamp, and the date ZIP keeps for every entry, together give a history of when the book was assembled. The cover is a separate picture file inside the archive and keeps its own EXIF data, the block of camera information stored inside a photo, which can include the camera make and model, the moment the shot was taken and GPS coordinates. Some shops also apply a watermark that puts the buyer's name or order number into the file.

When to choose EPUB

EPUB suits text you want to read comfortably on whatever device is to hand. The obvious alternative is PDF, and the difference is fixed pages. A PDF reproduces an exact page, which is what you want for sheet music, forms or anything with dense figures, but on a phone it means pinching and scrolling. EPUB gives that up and lets the text rewrap. Against Amazon's AZW3, EPUB wins on reach: it is readable on far more devices and apps, while a Kindle needs the file converted, either by you or by Amazon as it is delivered.