DevToolsmith

EPUB MIME Type

application/epub+zip is the MIME type for EPUB e-books. Here is the Content-Type header to send, the file signature, and how to configure servers and code.

MIME type
application/epub+zip
Extensions
.epub
Content-Type header
application/epub+zip
Registered
Yes, with IANA
Compress with gzip
No, it is already compressed
Category
Documents

About EPUB e-book files

An EPUB is a ZIP archive of XHTML, CSS and images. Like OpenDocument, it starts with an uncompressed mimetype file containing application/epub+zip, so readers can identify it without unzipping. Serving it with this type lets phones offer to open it in Apple Books or another reader app.

File signature

EPUB files start with 50 4B 03 04, then "mimetypeapplication/epub+zip" from byte 30. The extension and the type a browser reports for an upload both come from the file name, so check these bytes on the server before trusting a file.

Serve .epub with the right Content-Type

Response header
Content-Type: application/epub+zip
nginx (a line in the types { } block of mime.types)
application/epub+zip epub;
Apache (.htaccess or server config)
AddType application/epub+zip .epub
Caddy
@epub path *.epub
header @epub Content-Type "application/epub+zip"
Check what a server sends
curl -sI https://example.com/file.epub | grep -i '^content-type'
# Content-Type: application/epub+zip

Set the type in code

Node.js (Express)
res.set('Content-Type', 'application/epub+zip');
// Or make the browser download it:
res.attachment('file.epub');
Python
import mimetypes

mimetypes.add_type('application/epub+zip', '.epub')  # if your system doesn't know it
mimetypes.guess_type('file.epub')[0]  # 'application/epub+zip'
Go
mime.AddExtensionType(".epub", "application/epub+zip")
w.Header().Set("Content-Type", "application/epub+zip")

Accept .epub uploads

HTML
<input type="file" accept=".epub,application/epub+zip">

The accept attribute only filters the file picker; users can still choose another file. Listing the extension as well as the type matters, because operating systems don’t always report the type you expect.

Related types

  • .pdf (application/pdf): PDF document
  • .zip (application/zip): ZIP archive
  • .html (text/html): HTML

More documents

.doc , .docx , .xls , .xlsx , .ppt , .pptx , .odt , .rtf . Look up any extension or type with the MIME type lookup.

Sources

Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.

Frequently asked questions

What is the MIME type for .epub files?

application/epub+zip. The full header is "Content-Type: application/epub+zip".

Why does my server send the wrong Content-Type for .epub?

Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .epub is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".

How can I check that a file really is EPUB?

Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. EPUB files start with 50 4B 03 04, then "mimetypeapplication/epub+zip" from byte 30. The MIME type lookup on this site reads them for you when you drop a file on it.