Open Publication Structure eBook file

application/epub+zip

Safe

Magic Bytes

Offset: 0
50 4B 03 04

Open Publication Structure (EPUB) is an open-standard electronic book format developed by the International Digital Publishing Forum and maintained by the World Wide Web Consortium. It is the primary format for digital publications requiring reflowable text to provide consistent readability across various screen sizes and hardware e-readers. While structurally a ZIP archive of XHTML files, security is maintained through sandboxing features like JavaScript and remote resources within modern reading applications.

Extension

.epub

MIME Type

application/epub+zip

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .epub files in Python

Python
def is_epub(file_path: str) -> bool:
    """Check if file is a valid EPUB by magic bytes."""
    signature = bytes([0x50, 0x4B, 0x03, 0x04])
    with open(file_path, "rb") as f:
        return f.read(4) == signature

How to validate .epub files in Node.js

Node.js
function isEPUB(buffer: Buffer): boolean {
  const signature = Buffer.from([0x50, 0x4B, 0x03, 0x04]);
  return buffer.subarray(0, 4).equals(signature);
}
Go
func IsEPUB(data []byte) bool {
    signature := []byte{0x50, 0x4B, 0x03, 0x04}
    if len(data) < 4 {
        return false
    }
    return bytes.Equal(data[:4], signature)
}

API Endpoint

GET /api/v1/epub
curl https://filesignature.org/api/v1/epub

Related Formats