Professional EPUB tools for indie authors worldwide.
EpubBit guides/Workflow
Workflow

How to Compare Two EPUB or Manuscript Versions Without Losing Editorial Changes

Learn a reliable diff workflow for EPUB and manuscript versions: choose the right comparison level, normalize noise, preserve edits, and verify nothing is lost.

12 min read · EpubBit Editorial Team

You have two versions of your book: the editor's revised manuscript and your own pass, or an EPUB that was re-exported after a correction. You need to merge them without silently dropping changes. Comparing files sounds simple, but EPUB and manuscript formats introduce hidden variables—whitespace, markup, metadata, and generated files—that can make a trivial difference look like a rewrite or, worse, hide a real edit inside noise.

This guide gives you a repeatable workflow for comparing EPUB and manuscript versions at the right level of detail. You will learn how to choose a comparison granularity, normalize formatting noise, isolate editorial changes, merge safely, and verify that every intended change survived. The same method works for DOCX, Markdown, plain text, and EPUB, with small adjustments for each format.

1. Decide what “same” means before you compare

Before running any diff tool, define the unit of comparison. Comparing two EPUBs as binary files will almost always show a difference, even if the text is identical, because ZIP metadata and file ordering can change. Comparing two DOCX files as binary is equally noisy. You need to compare at the level where editorial changes actually live: usually the reading text, sometimes the markup, and rarely the package files.

Write down the scope of the comparison. For example:

  • Text-only comparison: Ignore all markup, metadata, and formatting. Use this to review copyedits, rewrites, and fact changes.
  • Markup-aware comparison: Include paragraph and inline tags. Use this when you need to catch changes in emphasis, links, or structure.
  • Package-level comparison: Include OPF, NCX, and navigation documents. Use this to verify metadata, reading order, and accessibility features.

A practical rule: run a text-only diff first to find editorial changes, then a markup-aware diff only on files that the text diff flagged. This reduces review time and prevents you from drowning in formatting changes.

2. Extract a clean, comparable text layer from EPUB

An EPUB is a ZIP container. The reading text lives in XHTML or HTML files, usually under a folder such as OEBPS/ or EPUB/. To compare two EPUBs, extract both to separate folders and identify the content documents listed in the OPF spine. Do not compare the raw ZIP bytes.

Step-by-step extraction and normalization:

  1. Unzip each EPUB into its own folder. Keep the original files untouched.
  2. Open the OPF package file and list the itemref entries in the spine. This is the reading order. Compare the same spine positions, not filenames, because filenames can change between exports.
  3. For each content document, strip tags to produce plain text. A simple command-line approach uses sed or a script, but be careful: naive tag stripping can merge words across paragraph boundaries. Insert a newline at block-level closing tags such as </p>, </h1>–</h6>, and <li> before stripping.
  4. Normalize whitespace: collapse runs of spaces and tabs to a single space, trim trailing spaces, and convert non-breaking spaces to regular spaces if your diff tool treats them as different characters.
  5. Normalize line endings to LF. Mixed CRLF and LF can create false differences on every line.
  6. Save the normalized text as one file per spine item, named by spine position, for example spine-001.txt.

If you use EpubBit, its inspection and validation views can help you confirm the spine order and spot structural changes before you extract text. Treat that as a pre-check, not a replacement for the diff itself.

Worked example: estimating diff noise

Suppose your EPUB has 40 content documents and 120,000 words. A raw XML diff might show 3,000 changed lines because an exporter changed indentation and attribute order. After text extraction and whitespace normalization, the same comparison might show 120 changed lines. That is a 25:1 reduction in review load. The exact ratio depends on your exporter, but the principle holds: normalize before you compare.

3. Choose the right diff granularity: line, word, or character

Most diff tools default to line-by-line comparison. That works for source code but is poor for prose, where a single changed word can shift the rest of a paragraph. Use word-level or character-level diff for editorial review, and line-level diff for structural checks.

Here is a practical decision guide:

  • Line diff: Good for checking whether a paragraph was added, removed, or moved. Fast to scan but hides small edits inside long paragraphs.
  • Word diff: Best for copyedits. Shows exactly which words changed while keeping surrounding text readable.
  • Character diff: Use for punctuation, hyphenation, and typographic fixes. Can be noisy on large documents, so restrict it to flagged paragraphs.

If your tool supports a three-way merge, use it when you have a common ancestor: for example, the original manuscript, the editor's version, and your version. A three-way merge can distinguish “changed by editor” from “changed by you” and reduce manual reconciliation.

4. Normalize formatting noise before you judge changes

Formatting noise is the enemy of a useful diff. Common sources include smart quotes versus straight quotes, em dashes versus en dashes, optional closing tags, attribute order, and generated IDs. Decide which differences are editorial and which are cosmetic, then normalize the cosmetic ones consistently on both sides.

A normalization checklist for prose:

  • Convert curly quotes to straight quotes, or vice versa, but do it on both versions. Do not normalize one side only.
  • Convert em dashes and en dashes to a single placeholder if your house style varies.
  • Collapse multiple spaces and remove trailing spaces.
  • Remove soft hyphens and zero-width characters that can appear after conversion.
  • Standardize ellipses to three periods if your diff tool treats the ellipsis character differently.

Keep a record of every normalization step. If a change disappears after normalization, you need to know whether it was cosmetic or whether you accidentally erased a real edit. A simple log file with the command or script used is enough.

Threshold check: when is a difference too large to review manually?

If a single spine document shows more than 15% of its words changed, stop and inspect the source. That often indicates a structural problem—such as a missing section, a duplicated chapter, or a conversion that dropped content—rather than a copyedit. Calculate the percentage as:

changed_words / max(total_words_version_a, total_words_version_b) * 100

For example, 900 changed words in a 6,000-word chapter is 15%. At that level, a word diff is still reviewable, but a line diff may be misleading. Above 30%, treat the document as rewritten and compare section headings first.

5. Compare manuscripts and EPUBs on a common footing

Comparing a DOCX manuscript to an EPUB is a cross-format comparison. You cannot diff them directly. Convert both to a common plain-text representation first, preserving paragraph boundaries and heading levels. Then compare.

For DOCX, extract text with paragraph breaks intact. Avoid copy-pasting from a word processor into a text editor, because that can introduce hidden characters. Use a conversion tool or export to plain text, then normalize. For Markdown, strip formatting syntax only if you want a text-only comparison; otherwise keep it, because Markdown headings and emphasis are meaningful editorial structure.

When comparing a manuscript to an EPUB, map headings to spine positions. A chapter that is a single DOCX heading may become multiple XHTML files in the EPUB. Compare chapter by chapter using the table of contents as your guide, not raw filenames.

6. Review changes in a fixed order to avoid missing edits

A diff tool shows differences, but it does not tell you which ones matter. Review in a consistent order so you do not skip categories of change.

  1. Structural changes first: added or removed chapters, reordered sections, changed heading levels.
  2. Paragraph-level changes: new paragraphs, deleted paragraphs, moved paragraphs.
  3. Word-level changes: substitutions, insertions, deletions within paragraphs.
  4. Punctuation and typography: quote style, dashes, spacing.
  5. Metadata and navigation: title, author, language, identifiers, and TOC labels.

For each change, decide: accept, reject, or flag for author query. Record the decision in a merge log with the spine position and a short description. This log becomes your audit trail if a change goes missing later.

7. Merge safely: never edit the only copy

Always merge into a new working copy. Keep the original EPUB and the editor's version untouched. If you are merging text, apply changes to the source manuscript or to a fresh export, not to a file that is already published.

A safe merge sequence:

  1. Create a working folder with three subfolders: base, incoming, and merged.
  2. Copy the version you will edit into merged.
  3. Apply accepted changes one at a time or in small batches. After each batch, run a diff against the previous merged state to confirm only intended changes were applied.
  4. Re-export to EPUB from the merged source if possible. If you must edit the EPUB directly, edit the XHTML files and then rebuild the container.
  5. Run EPUBCheck or your validator on the merged EPUB. A merge that breaks markup can pass a text diff but fail validation.

EpubBit fits naturally at the validation step: after merging and re-exporting, use it to check that the package still validates and that the spine order and metadata are intact. That catches structural regressions that a text-only diff cannot see.

8. Verify that no editorial change was lost

Verification is not the same as reviewing the diff. You need positive evidence that every accepted change exists in the merged file. Use a combination of automated checks and spot checks.

Automated checks:

  • Re-run the text diff between the merged version and the incoming version. The only remaining differences should be changes you deliberately rejected.
  • Count words per spine item in both versions. A difference of more than 2% in a chapter that was not intentionally rewritten is a red flag.
  • Check that every heading in the incoming TOC exists in the merged TOC, and vice versa.
  • Validate the merged EPUB and confirm zero new errors compared with the incoming version.

Spot checks:

  • Pick five changed paragraphs at random and confirm the accepted wording appears in the merged file.
  • Check the first and last paragraph of each changed chapter.
  • Confirm that deleted paragraphs are actually gone, not merely hidden by a display style.

Worked example: word-count verification

Suppose the incoming chapter has 4,200 words and your merged chapter has 4,180 words. You accepted a deletion of 30 words and rejected an insertion of 10 words. Expected merged count: 4,200 − 30 = 4,170. Your actual count is 4,180, which is 10 words high. That suggests the rejected insertion may have been applied accidentally, or another small change was missed. Investigate before publishing.

9. Handle metadata and navigation separately

Editorial changes often come with metadata updates: a new subtitle, a revised series name, or a changed ISBN. Compare metadata fields explicitly rather than relying on a text diff. Extract the OPF and compare these fields one by one:

  • dc:title and any subtitle or title-type refinements
  • dc:creator and contributor roles
  • dc:language
  • dc:identifier and ISBN
  • Series metadata and collection type
  • Accessibility metadata, if present

Navigation deserves its own check. A changed chapter title should appear in both the NCX and the EPUB 3 navigation document. If you merge text but forget the TOC label, readers will see the old title in their navigation pane. Compare TOC labels against the first heading of each spine item; they should match unless you deliberately use a shorter label.

10. Build a repeatable comparison protocol

The best way to avoid losing changes is to make the comparison boring and repeatable. Write a short protocol and follow it every time. A minimal protocol looks like this:

  1. Record the source file names, dates, and word counts for both versions.
  2. Extract text from both versions using the same normalization script.
  3. Run a text-only diff first; flag chapters with more than 15% changed words.
  4. Review flagged chapters with a word-level diff.
  5. Merge into a new working copy; never overwrite the originals.
  6. Re-export and validate the merged EPUB.
  7. Run a final diff against the incoming version and confirm only rejected changes remain.
  8. Archive the originals, the merge log, and the final EPUB together.

Keep the protocol in your project folder. When a change goes missing six months later, the log tells you whether it was ever merged.

Conclusion

Comparing EPUB and manuscript versions without losing editorial changes comes down to three habits: compare at the right level, normalize formatting noise consistently, and verify the merged result with both a diff and a validator. Extract clean text, review structural changes before word-level changes, merge into a fresh copy, and check word counts and TOC labels against your merge log. None of these steps requires expensive software, but they do require discipline. Follow them and you can reconcile two versions with confidence instead of hope.