.EPUB Electronic Publication
.epub

Electronic Publication

EPUB is a ZIP archive containing XHTML content, CSS, images, and an OPF package document, identified by an uncompressed mimetype file at offset 0 containing exactly application/epub+zip. The W3C maintains the current EPUB 3.3 specification (2023).

بنية الصيغة
Header version
Body content tree
Index references
eBookapplication/epub+zipZIP ContainerXHTML + CSSIDPF 2007W3C EPUB 3.3
بواسطة FileDex
غير قابل للتحويل

EPUB rendering requires a full e-book layout engine with pagination not available in browser WASM.

تبحث عن تحويل؟ جرّب صيغة ذات صلة:

أسئلة شائعة

Can I read EPUB files on a Kindle?

Older Kindle models require conversion to MOBI or AZW3 using Calibre. Kindle firmware released after late 2022 and the Send to Kindle service accept EPUB files directly, converting them to KF8 on ingestion. Kindle Scribe and newer Paperwhite models handle EPUB without manual conversion.

How do I remove DRM from an EPUB I purchased?

DRM removal depends on the DRM system used (Adobe ADEPT, Apple FairPlay, or Readium LCP). Tools exist but their legality varies by jurisdiction. A DRM-free alternative is purchasing from stores that sell unencrypted EPUB files (e.g., Kobo Plus, Smashwords, or publisher direct sales).

Why does my EPUB fail validation in EPUBCheck?

The most common failures are: mimetype entry not first in ZIP or compressed instead of stored, missing META-INF/container.xml, XHTML files with invalid markup (unclosed tags, missing xmlns), and manifest items referencing files not present in the ZIP. Run epubcheck with --info flag for detailed diagnostics.

What is the difference between EPUB 2 and EPUB 3?

EPUB 2 uses XHTML 1.1, DTBook, and NCX for navigation. EPUB 3 upgrades to HTML5, CSS3, SVG, MathML, JavaScript (sandboxed), and replaces NCX with an XHTML Navigation Document. EPUB 3 also adds media overlays (synchronized audio via SMIL) and improved accessibility metadata.

ما يميز .EPUB

What is an EPUB file?

EPUB (Electronic Publication) is the most widely supported open eBook format. Developed by the IDPF (now part of W3C), EPUB files are ZIP archives containing XHTML content, CSS styling, images, and metadata. EPUB 3 supports reflowable and fixed-layout content, audio, video, and interactive elements.

اكتشف التفاصيل التقنية

How to open EPUB files

  • Apple Books (macOS, iOS) — Built-in
  • Calibre (Windows, macOS, Linux) — Free, feature-rich
  • Kobo eReaders — Native EPUB support
  • Google Play Books (Android, Web) — Upload and read

Technical specifications

Property Value
Format ZIP with XHTML/CSS
Current Version EPUB 3.3 (W3C)
Layout Reflowable or fixed
DRM Adobe DRM, Apple FairPlay
Accessibility Full WCAG support in EPUB 3

Common use cases

  • eBooks: Commercial and self-published digital books.
  • Digital magazines: Rich media periodicals.
  • Documentation: Technical manuals and guides.
  • Academic publishing: Textbooks and research papers.

المرجع التقني

نوع MIME
application/epub+zip
Magic Bytes
50 4B 03 04 ZIP archive. Contains mimetype file with application/epub+zip.
المطوّر
International Digital Publishing Forum (IDPF)
سنة التقديم
2007
معيار مفتوح
نعم — عرض المواصفات
00000000504B0304 PK..

ZIP archive. Contains mimetype file with application/epub+zip.

البنية الثنائية

EPUB files are ZIP archives with specific structural requirements. The ZIP local file header starts with magic bytes 50 4B 03 04 (PK). The first file entry in the ZIP MUST be named 'mimetype' and MUST contain exactly the ASCII string 'application/epub+zip' (no trailing newline, no extra whitespace). This mimetype entry MUST be stored uncompressed (compression method 0x0000 in the local file header) and MUST have no extra field data in its local file header (extra field length = 0x0000). This allows detection tools to find the string 'application/epub+zip' at a fixed offset (byte 38) in the file without decompressing. After the mimetype entry, the ZIP contains: META-INF/container.xml (points to the root file, typically OEBPS/content.opf or OPS/content.opf), the OPF package document (manifest of all content files, spine reading order, metadata), XHTML content documents, CSS stylesheets, image assets (JPEG, PNG, SVG), optional NCX (EPUB 2) or XHTML nav document (EPUB 3) for table of contents, and optional fonts (OTF, WOFF). EPUB 3 adds support for MathML, JavaScript (restricted), media overlays (SMIL for synchronized audio), and the EPUB Navigation Document replacing the NCX.

OffsetLengthFieldExampleDescription
0x00 4 bytes ZIP Local File Header Signature 50 4B 03 04 (PK) Standard ZIP local file header magic. Present because EPUB is a constrained ZIP archive.
0x1A 2 bytes Filename Length 08 00 (8 bytes) Length of the filename field. For the first entry, this must be 8 (the string 'mimetype').
0x1C 2 bytes Extra Field Length 00 00 Must be 0 for the mimetype entry. Any extra field data shifts the mimetype string offset and breaks EPUB detection.
0x1E 8 bytes Filename 6D 69 6D 65 74 79 70 65 (mimetype) First file entry filename. Must be exactly 'mimetype' for valid EPUB.
0x26 20 bytes Mimetype Content application/epub+zip Uncompressed content of the mimetype file. No trailing newline or whitespace allowed.
1999Open eBook Publication Structure (OEB) 1.0 published by the Open eBook Forum — EPUB's direct predecessor2007EPUB 2.0 released by IDPF — introduces OPF, OCF (ZIP container), and NCX table of contents2011EPUB 3.0 released — adds HTML5/CSS3, MathML, JavaScript (restricted), media overlays (SMIL), EPUB Navigation Document2014EPUB 3.0.1 — clarifications and errata, improved accessibility requirements2017IDPF merges with W3C — EPUB specification governance moves to W3C Publishing Working Group2019EPUB 3.2 published by W3C — aligns with current web standards, deprecates features, adds WOFF2 font support2023EPUB 3.3 published as W3C Recommendation — improved accessibility conformance, origin-based security model for scripted content
Convert EPUB to PDF via Calibre أخرى
ebook-convert input.epub output.pdf

Calibre's ebook-convert renders EPUB content to paginated PDF using its internal layout engine. Supports options for page size (--paper-size), margins, and font overrides.

Validate EPUB with epubcheck أخرى
java -jar epubcheck.jar input.epub

EPUBCheck is the official W3C validation tool for EPUB files. It verifies OCF container structure, OPF manifest completeness, XHTML validity, and mimetype entry conformance. Exit code 0 means valid.

Extract EPUB contents as plain files أخرى
unzip -o input.epub -d epub_contents/

Since EPUB is a ZIP archive, standard unzip extracts all XHTML, CSS, images, and metadata files into a directory for manual inspection or editing.

Repackage extracted EPUB (mimetype first, uncompressed) أخرى
cd epub_contents && zip -X0 ../output.epub mimetype && zip -rX9 ../output.epub * -x mimetype

Creates a valid EPUB ZIP with the mimetype entry first and uncompressed (-0), then adds all other files with maximum compression (-9). The -X flag strips extra fields from the mimetype entry.

EPUB PDF render near-lossless PDF locks down page layout, fonts, and margins for print-ready output. EPUB reflowable content has no fixed pagination — converting to PDF produces a deterministic page sequence suitable for printing, academic submission, or DRM-free archival.
EPUB MOBI transcode near-lossless Kindle devices and the Kindle app on older firmware do not support EPUB natively. Converting to MOBI (or KF8/AZW3) is required for sideloading content to Kindle hardware. Amazon's Send to Kindle service now accepts EPUB directly, but legacy Kindle models still need MOBI.
EPUB TXT export lossy Extracts raw text content from all XHTML chapters, stripping markup, images, and styling. Useful for full-text indexing, corpus analysis, or feeding content to text processing pipelines.
متوسط

نقاط الضعف

  • Malicious JavaScript in scripted content documents — EPUB 3 allows restricted JS that could exploit reader app vulnerabilities or exfiltrate reading behavior if the reader does not sandbox scripts properly
  • Path traversal via ZIP entry names — crafted filenames like ../../etc/passwd in the ZIP can escape the extraction directory on vulnerable tools (Zip Slip vulnerability)
  • XML External Entity (XXE) injection — XHTML or OPF content referencing external entities can trigger server-side request forgery or local file disclosure in readers that resolve DTD references
  • Embedded font exploits — malformed OTF/TTF font files inside EPUB can trigger memory corruption in font rendering engines (historical: FreeType CVEs)

الحماية: FileDex processes EPUB files entirely in the browser sandbox. No server upload occurs, no JavaScript within the EPUB is executed, and ZIP extraction operates within the browser's memory sandbox without filesystem write access. Font rendering uses the browser's built-in engine with its own security boundary.

Calibre أداة
Open-source eBook manager with EPUB creation, conversion, and library management
EPUBCheck أداة
W3C official EPUB validation tool — checks OCF, OPF, XHTML, and accessibility
Sigil أداة
WYSIWYG EPUB editor with code view, metadata editing, and validation
Pandoc أداة
Universal document converter supporting EPUB 2/3 as both input and output
epub.js مكتبة
JavaScript library for rendering EPUB in web browsers with pagination
Apple Books أداة
Built-in macOS/iOS EPUB reader with native EPUB 3 rendering and accessibility