<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/merging-multiple-epubs-into-a-single-file-for-amazon-kindle-1lc58sikx" -->

---
title: Merging multiple EPUBs into a single file for Amazon Kindle
description: A practical walkthrough of merging 13 separate EPUB files into a single valid EPUB for Kindle reading. The post explains EPUB internals (it's a ZIP with an XML...
canonical: https://daily.dev/posts/merging-multiple-epubs-into-a-single-file-for-amazon-kindle-1lc58sikx
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Merging multiple EPUBs into a single file for Amazon Kindle | daily.dev
og:description: A practical walkthrough of merging 13 separate EPUB files into a single valid EPUB for Kindle reading. The post explains EPUB internals (it's a ZIP with an XML...
og:url: https://daily.dev/posts/merging-multiple-epubs-into-a-single-file-for-amazon-kindle-1lc58sikx
og:image: https://api.daily.dev/og/posts/1lC58Sikx.png
og:image:alt: Merging multiple EPUBs into a single file for Amazon Kindle
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Merging multiple EPUBs into a single file for Amazon Kindle

**[Mattias Geniar](https://daily.dev/sources/mattiasgeniar)** · 7 min read · 0 upvotes · 0 comments

## Summary

A practical walkthrough of merging 13 separate EPUB files into a single valid EPUB for Kindle reading. The post explains EPUB internals (it's a ZIP with an XML manifest), the namespace-per-book directory strategy to avoid CSS and filename collisions, epubcheck validation gotchas (mimetype must be first and uncompressed, all files must be in the manifest, identifiers must be real UUIDs), and how to deliver the result to a Kindle. It also notes that Send to Kindle rejects AZW3 uploads and converts EPUB server-side anyway, making a valid EPUB the only file needed. The script was built almost entirely with Claude Opus 4.8.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://ma.ttias.be/merging-epubs-single-kindle-file>

## Questions this post answers

### Does Amazon Send to Kindle accept AZW3 files or only EPUB?

Send to Kindle rejects AZW3 uploads. Its web uploader and email gateway accept EPUB, PDF, Word, and a handful of other formats, but not AZW3. When you send an EPUB, Amazon converts it to AZW3 on their own servers. AZW3 only earns its keep when copying directly to the device over USB, and modern Kindles accept EPUB that way too.

_Developers navigating Kindle format choices find the latest Send to Kindle constraints covered on daily.dev._

### Why does epubcheck complain that mimetype must be the first entry in the ZIP?

The EPUB spec requires mimetype to be the very first entry in the ZIP archive and stored uncompressed (ZIP_STORED). Python's zipfile module won't enforce this automatically — you must write the mimetype entry first with compress_type=zipfile.ZIP_STORED before adding any other files with ZIP_DEFLATED. Skipping this causes a hard validation error, not just a warning.

_Those working through EPUB tooling edge cases like this track related findings on daily.dev._

### How do I avoid CSS class name collisions when merging multiple EPUB files into one?

Give each source book its own subdirectory inside the merged EPUB's OEBPS folder (e.g. book01/, book02/). Each book's XHTML then references its own local stylesheet.css sitting next to it, so identically named classes like c1 and c2 never cross-contaminate. No class renaming or CSS reconciliation is needed — directory isolation handles it entirely.

_Developers tackling EPUB manipulation or similar file-format scripting projects find relevant walkthroughs on daily.dev._

## Similar posts on daily.dev

- [How HTML changes in ePub](https://daily.dev/posts/how-html-changes-in-epub-xowwbafo4) · Lobsters · 4 upvotes · 0 comments
- [Your Kindle doesn't need to be hacked to escape Amazon's walled garden](https://daily.dev/posts/your-kindle-doesn-t-need-to-be-hacked-to-escape-amazon-s-walled-garden-t9rgtnstk) · XDA Developers · 0 upvotes · 0 comments
- [How to write a book on your phone and export ePub or PDF](https://daily.dev/posts/how-to-write-a-book-on-your-phone-and-export-epub-or-pdf-szqccuxyx) · Medium · 0 upvotes · 0 comments
- [I turned my Kindle into my own personal newspaper](https://daily.dev/posts/i-turned-my-kindle-into-my-own-personal-newspaper-scgbgzn5x) · Hacker News · 1 upvotes · 0 comments
- [Amazon changes how copyright protection is applied to Kindle Direct’s self-published ebooks](https://daily.dev/posts/amazon-changes-how-copyright-protection-is-applied-to-kindle-direct-s-self-published-ebooks-o4dohoi1a) · TechCrunch · 0 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python)

[View this post on daily.dev](https://daily.dev/posts/merging-multiple-epubs-into-a-single-file-for-amazon-kindle-1lc58sikx)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Merging multiple EPUBs into a single file for Amazon Kindle","url":"https://daily.dev/posts/merging-multiple-epubs-into-a-single-file-for-amazon-kindle-1lc58sikx","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/merging-multiple-epubs-into-a-single-file-for-amazon-kindle-1lc58sikx"},"datePublished":"2026-08-11T08:51:45.552Z","dateModified":"2026-08-11T08:52:29.884Z","description":"A practical walkthrough of merging 13 separate EPUB files into a single valid EPUB for Kindle reading. The post explains EPUB internals (it's a ZIP with an XML...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/64bc01652e1579cd873fd68dd845838b?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/64bc01652e1579cd873fd68dd845838b?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Mattias Geniar","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Mattias Geniar","logo":"https://media.daily.dev/image/upload/logos/placeholder.jpg","url":"https://daily.dev/sources/mattiasgeniar"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/merging-multiple-epubs-into-a-single-file-for-amazon-kindle-1lc58sikx","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Mattias Geniar","item":"https://daily.dev/sources/mattiasgeniar"},{"@type":"ListItem","position":3,"name":"Merging multiple EPUBs into a single file for Amazon Kindle"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/merging-multiple-epubs-into-a-single-file-for-amazon-kindle-1lc58sikx#faq","mainEntity":[{"@type":"Question","name":"Does Amazon Send to Kindle accept AZW3 files or only EPUB?","acceptedAnswer":{"@type":"Answer","text":"Send to Kindle rejects AZW3 uploads. Its web uploader and email gateway accept EPUB, PDF, Word, and a handful of other formats, but not AZW3. When you send an EPUB, Amazon converts it to AZW3 on their own servers. AZW3 only earns its keep when copying directly to the device over USB, and modern Kindles accept EPUB that way too. Developers navigating Kindle format choices find the latest Send to Kindle constraints covered on daily.dev."}},{"@type":"Question","name":"Why does epubcheck complain that mimetype must be the first entry in the ZIP?","acceptedAnswer":{"@type":"Answer","text":"The EPUB spec requires mimetype to be the very first entry in the ZIP archive and stored uncompressed (ZIP_STORED). Python's zipfile module won't enforce this automatically — you must write the mimetype entry first with compress_type=zipfile.ZIP_STORED before adding any other files with ZIP_DEFLATED. Skipping this causes a hard validation error, not just a warning. Those working through EPUB tooling edge cases like this track related findings on daily.dev."}},{"@type":"Question","name":"How do I avoid CSS class name collisions when merging multiple EPUB files into one?","acceptedAnswer":{"@type":"Answer","text":"Give each source book its own subdirectory inside the merged EPUB's OEBPS folder (e.g. book01/, book02/). Each book's XHTML then references its own local stylesheet.css sitting next to it, so identically named classes like c1 and c2 never cross-contaminate. No class renaming or CSS reconciliation is needed — directory isolation handles it entirely. Developers tackling EPUB manipulation or similar file-format scripting projects find relevant walkthroughs on daily.dev."}}]}
```

