Word to EPUB

A .docx and an EPUB are both zip archives full of XML, which is why converting one to the other looks trivial, and why the results are so reliably poor. Here is what actually has to happen in between.

Both formats are zip files. Rename either one to .zip, open it, and you find XML. The naive conversion (pull the paragraphs out of one, wrap them in tags, put them in the other) takes an afternoon to write, which is why there are two hundred sites offering it and why their output is recognisable at a glance.

What follows is the distance between that and a file worth selling, step by step.

1. Undo Word’s run splitting


Word stores text in runs: stretches that share formatting. In theory one italicised phrase is one run. In practice Word splits a run at every spell-check boundary, every language detection, every revision save, so the word “lighthouse” in italics routinely arrives as three runs.

Emit one element per run and you get <em>light</em><em>ho</em><em>use</em>. Many reading systems render that with hairline gaps, and all of them handle it worse than a single element. The first thing any serious reader of DOCX does is coalesce adjacent runs with identical formatting, and before building any tree, because afterwards the information needed to compare them is gone.

2. Know which parts of the file are lies


Several things in a DOCX look like content and are not. Reading them is how a converter puts nonsense in a book.

What it looks likeWhat it isWhat to do
w:lastRenderedPageBreakWord's cache of where the page broke on the last machine that opened the file, at that machine's marginsIgnore it entirely
w:instrTextField code: the literal text PAGEREF _Toc4219 \h, not something a reader should seeNever read it as text
w:delText inside w:delText the author deleted with track changes onLeave it out, and say how much was left out
A one-cell tableWord's way of drawing a box around a paragraph: a sidebar, not dataRead it as a block quote, not a 1×1 table
A table of contents with page numbersNumbers that stopped being true the moment the book was re-typeset, and that mean nothing in a reflowable ebookRemove it and generate a real one
w:b with w:val="0"Bold switched OFF inside a bold contextRead the value, not the presence of the element

3. Find the chapters


An EPUB is a sequence of documents. A manuscript is one long flow. Splitting it is the step that decides whether the result is a book, and there are three kinds of manuscript in the world:

  • The author used Heading 1. The easy case, and the only one most converters handle. One detail even here: match on the style’s name, not its id. A French Word writes w:styleId="Titre1" and a German one writes Überschrift1; both carry w:name="heading 1". Matching the id works on English documents and silently flattens everyone else’s chapters into body text.
  • The author pressed Ctrl+Enter between chapters and typed the titles in bold, centred, 16pt. This is the most common manuscript there is. Word knows nothing about it, since every paragraph is styled Normal. Split on the page breaks, then look at the first line of each piece to see whether it is a title and promote it if so, because otherwise the printed book carries every chapter title twice.
  • Neither. A continuous flow with lines reading “Chapter Seven”. Scan for them, and tell the author that is what you did.

4. Fix the typography


A manuscript is typed. A book is set. The differences are small individually and cumulative in effect:

  • Straight quotes become typographic ones, and contextually, so that ’tis and the ’90s get an apostrophe rather than an opening quote. The hard part is doing it across formatting boundaries: the apostrophe in <em>don</em>’t has its antecedent in a different element.
  • Double hyphens become em dashes, three dots become an ellipsis.
  • The double space after a full stop goes. It is a typewriter convention for monospaced type and it leaves holes in a proportional face.
  • Tabs at the head of a paragraph go. Indentation is a typographic decision, not text.
  • A paragraph containing only * * * becomes a scene break, with the glyph decided by the design rather than left as three literal asterisks.

5. Build a package that validates


An EPUB 3 is not “some XHTML in a zip”. Five things are required and all five are what generic converters get wrong:

RequirementWhy it fails
mimetype first in the archive, stored uncompressedThe format is designed so a reader can identify the file from its first thirty bytes. A writer that compresses it produces an archive most reading systems refuse, and the failure looks like a corrupt file rather than like a bug
dcterms:modified in exactly YYYY-MM-DDThh:mm:ssZThe single most common EPUB 3 validation error. Milliseconds are not allowed
A unique identifier the package namesTwo editions sharing an identifier means a reading system treats the second as an update to the first and silently replaces it
A navigation document declared with properties="nav"Without it there is no contents menu, whatever the file contains
Every file manifested, and every manifested file presentAn image left out of the manifest is an error; one listed but absent is also one

And three things that are not required, and matter

  • Landmarks. They are what a reading system’s “go to the beginning” uses. Without them, the book opens on the cover or the copyright page and every reader starts by swiping past the front matter.
  • Semantic sections. An epub:type and a matching ARIA role on each section is what distinguishes a chapter from a copyright page, for a reading system and for a screen reader.
  • Accessibility metadata. Since June 2025 this is close to mandatory for ebooks sold in the EU. See accessible EPUB.

6. Write a stylesheet that gets out of the way


The hardest thing to accept about ebook CSS is how little of it there should be. Three rules account for most bad EPUBs:

  • Never set a font size in points or pixels. The reader chose a size, on a device you have never seen, sometimes for their eyesight. Overriding it is the single most damaging thing an ebook stylesheet can do.
  • Never set a text colour or a background. A book that specifies color: #000 is unreadable in night mode: the reading system darkens the background and the author’s black text stays black.
  • Never set margins on the body. The reading system owns the page margins. Adding more produces a text block that shrinks every time the reader widens theirs.

What a stylesheet should do is set the relationships: the indent, which paragraphs are exempt from it, the space around a block quote, what a scene break looks like, all in units that scale with whatever the reader picked. That is the whole of good ebook CSS and it fits on a page.

Questions


Can I just use a free online DOCX to EPUB converter?
You can, and the file will usually open. What it will not do is split into chapters correctly, set the first paragraph of each chapter unindented, carry a navigable table of contents, declare its own accessibility, or survive a close look on an e-ink screen. The community verdict in self-publishing forums is blunt about this: the free ones are amateur quality and the cheap paid ones are worse.
Why does my converted EPUB have gaps inside italic words?
Because Word splits a run of text at every spell-check boundary, every language switch and every revision save, so one italicised word commonly arrives as five or six separate runs. A converter that emits one element per run produces <em>w</em><em>or</em><em>d</em>, and reading systems render that with hairline gaps. The fix is to merge adjacent runs with identical formatting before generating anything.
Why are there random page breaks in my converted file?
Almost certainly because the converter read w:lastRenderedPageBreak as a page break. It is not one: it is Word's cache of where the page happened to break on the machine that last opened the document, at that machine's margins and paper size. Converters that trust it scatter breaks through the book at a previous reader's page geometry.
What is actually inside an EPUB file?
A zip archive. Inside it: a mimetype file, a container pointing at a package document, the package document listing every file and the order to read them in, a navigation document, and one XHTML file per chapter with a stylesheet. Rename an EPUB to .zip and you can open it and look.
Should I upload DOCX or EPUB to Amazon?
EPUB, if you have a good one. KDP accepts DOCX and converts it, which means its converter makes every decision about your book (chapter breaks, indents, spacing) and you see the result only in its previewer. Uploading an EPUB means you decided.
Does an EPUB need a cover image inside it?
For Amazon, no: KDP takes the Kindle cover from the dashboard. For every other retailer and for the reader's own library view, yes, and an EPUB with no cover shows as a grey rectangle with a title on it.

Try it on your own manuscript


Open a Word file and see the EPUB and the printed pages in a few seconds. Free, no account, and the manuscript never leaves your browser.

Format a book