Electronic Publication is a document format commonly identified by .epub. Use the listed signatures, MIME types, and structure notes to validate files beyond the extension.
Do not trust the extension alone. Check the MIME type, the first bytes such as 50 4B 03 04, and format-specific structure when possible.
Container formats and damaged files can share the same opening bytes, so deeper validation may be required for production upload, preview, or conversion flows.
Detection example
SIGNATURE = bytes.fromhex("504b0304")
OFFSET = 0
def is_epub(path: str) -> bool:
with open(path, "rb") as f:
f.seek(OFFSET)
head = f.read(len(SIGNATURE))
return head == SIGNATURE
const SIGNATURE = [0x50, 0x4b, 0x03, 0x04];
const OFFSET = 0;
// bytes: a Uint8Array / Buffer holding the start of the file
export function isEpub(bytes) {
return SIGNATURE.every((byte, i) => bytes[OFFSET + i] === byte);
}
package fileid
import "bytes"
var isepubSignature = []byte{0x50, 0x4b, 0x03, 0x04}
const isepubOffset = 0
func IsEpub(b []byte) bool {
end := isepubOffset + len(isepubSignature)
if len(b) < end {
return false
}
return bytes.Equal(b[isepubOffset:end], isepubSignature)
}
Electronic Publication is used for data exchange, imports, exports, parser testing, and validation workflows. Encoding, delimiters, versions, and container structure often change implementation behavior.
Common detection mistakes
The .epub extension alone does not prove the file contents. Upload and conversion flows should combine extension, MIME type, leading bytes, and format-specific structure checks.
Electronic Publication can start with signatures such as 50 4B 03 04, but related containers and damaged files may require additional validation.
Security notes
Document formats may include scripts, attachments, macros, or external references. Sandbox previews and conversions, and avoid opening untrusted files directly.
Using samples
11 samples help test leading-byte detection, parser errors, upload limits, and download behavior.
Blue Sky EPUB is a Electronic Publication sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Flower Garden EPUB is a Electronic Publication sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Navy Blue Sky EPUB is a Electronic Publication sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Nature of the Sky EPUB is a Electronic Publication sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Sky Landscape EPUB is a Electronic Publication sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Starry Sky EPUB is a Electronic Publication sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Blue Night Sky EPUB is a Electronic Publication sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Hibiscus Flower EPUB is a Electronic Publication sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Arctic Sky EPUB is a Electronic Publication sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
Sunset Rays EPUB is a Electronic Publication sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.
NASA Blue Marble EPUB is a Electronic Publication sample based on NASA Image and Video Library. It can be used to test downloads, parsers, previews, and file type detection.
What is the magic number (file signature) of Electronic Publication?
Electronic Publication files begin with the byte signature 50 4B 03 04 ("PK.."). Detect the format by reading these leading bytes rather than trusting the file extension alone.
What is the MIME type of Electronic Publication?
The MIME type for Electronic Publication is application/epub+zip.
What file extension does Electronic Publication use?
Electronic Publication files use the .epub extension. The extension is a convention only and does not guarantee the file contents, so combine it with signature and structure checks.