EPUB Ghost Spacing & OPF Errors: How to Find and Fix Them
Your EPUB looks perfect in Calibre. It previews fine on your phone. Then Apple Books rejects it — or worse, it publishes but readers report broken formatting on certain devices. Ghost spacing and OPF manifest errors are usually why.
These two problems are invisible. You won't see them in Word, in Sigil, or even in the KDP previewer. But they're sitting inside your file, and stricter platforms will catch them every time. This guide covers what both problems are, what error messages they produce, and how to fix each one step by step.
What Is EPUB Ghost Spacing?
Ghost spacing is what you get when automated converters try to preserve your original Word or Google Docs formatting. To do it, tools like Calibre and Google Docs export inject thousands of empty HTML tags into your file.
Instead of clean paragraph spacing, your EPUB ends up with markup that looks like this:
<p><span style="margin:0;padding:0"></span></p>
<p><br/></p>
<p> </p>
<p style="margin-top:0pt;margin-bottom:0pt;"></p>
On screen, you see a normal gap between paragraphs. Inside the file, there are multiple layers of empty tags creating that gap. Multiply that by 300 pages and your EPUB has tens of thousands of ghost elements that serve no purpose except bloating the file and confusing validators.
Apple Books and Google Play Books parse the full HTML structure before rendering. When they find this kind of bloat, they flag the file as poorly formed — and reject it, sometimes with no explanation beyond a generic content error.
What Are OPF Manifest Errors?
The OPF file (usually content.opf or package.opf) is the manifest that tells reading systems what's in your EPUB — every chapter file, every image, every CSS file. It also defines reading order and metadata.
OPF errors fall into several categories:
- Missing items: A file exists in your EPUB but isn't listed in the manifest. The file gets ignored by reading systems.
- Dead references: The manifest lists a file that doesn't exist in the package. Validation fails immediately.
- Wrong media types: An image is listed as
image/jpginstead ofimage/jpeg. Small typo, hard rejection on strict platforms. - Duplicate IDs: Two manifest items share the same ID attribute. Parsing breaks unpredictably across different reading systems.
- Spine order errors: The reading order in the spine doesn't match the manifest, or the spine references IDs that don't exist. Chapters load out of sequence or not at all.
- Missing nav properties: EPUB 3.0 nav documents need
properties="nav"in their manifest item — without it, reading systems don't recognize the navigation document.
Most OPF errors come from converting files manually or editing EPUBs in tools that don't update the manifest automatically when you rename or delete files.
Real Error Messages You'll See
When EPUBCheck or a platform validator catches these problems, the output looks like this:
ERROR(OPF-003): content.opf(42,18): item 'chapter05.xhtml' exists in the EPUB
but is not referenced in the spine.
ERROR(OPF-032): content.opf(87,12): manifest item 'Images/fig-02.png'
referenced in content but not found in the EPUB.
ERROR(OPF-014): content.opf(31,10): duplicate manifest ID 'chapter03'.
WARNING(HTM-025): chapter03.xhtml(156,1): empty paragraph found — possible
ghost spacing artifact from word processor export.
ERROR(PKG-021): item 'stylesheet.css' exists in the EPUB but is not listed
in the manifest.
The numbers in parentheses are line and column references in the file where the error occurs. OPF-003, OPF-032, OPF-014 are manifest errors. HTM-025 warnings signal ghost spacing. PKG-021 means a file exists but isn't declared.
Apple Books sends a rejection email that typically says something like: "We were unable to process your book because it contains content errors. Please review your file and resubmit." No specific error code. That's why running a validator before submitting is essential — Apple's email won't tell you what line to fix.
How to Find Ghost Spacing in Your EPUB
The fastest method is the EPUB Validator. It flags structural bloat alongside spec errors — you'll see exactly which chapter files have ghost tag accumulation and how severe it is.
For manual inspection: unzip your EPUB (rename to .zip, extract) and open a chapter file in a text editor. Search for sequences of empty <p> and <span> tags. Run a find for <p></p> and note how many hits you get. More than 10 per 5,000-word chapter is a red flag. More than 50 means the whole book needs cleaning before any strict platform will accept it.
How to Fix Ghost Spacing: Step by Step
Mild cases (under 20 ghost elements per chapter):
- Unzip the EPUB and open each chapter file in a text editor.
- Use find-and-replace to delete
<p></p>— replace with nothing. - Delete
<p> </p>occurrences. - Delete
<p><br/></p>— or replace with a single<br/>if the break is intentional. - Search for
<span style="— if the span contains empty content or zero-width styling only, delete the span and keep its text content. - Repackage (mimetype first, uncompressed), revalidate, upload.
Severe cases (hundreds of ghost elements throughout):
Manual patching is impractical at this scale. The cleanest fix is returning to your manuscript, stripping all formatting, and running it through a proper EPUB formatter that builds clean HTML from scratch. The EPUB Formatter generates lean EPUB 3.0 HTML without the ghost tag layers that converters produce.
How to Fix OPF Manifest Errors: Step by Step
- Run validation first. Upload your EPUB to the EPUB Validator and save the full report. Don't try to find errors manually — the validator gives you the complete list with exact file and line references.
- Unzip the EPUB. Rename to .zip and extract to a folder.
- Open
content.opfin a text editor. Find the<manifest>and<spine>sections. - For dead references: Remove the manifest item that points to a missing file. If the error says
Images/fig-02.png not found, delete<item id="fig-02" href="Images/fig-02.png" media-type="image/png"/>. - For unlisted files: Add a manifest item for every existing file that isn't declared. Get the media-type right:
application/xhtml+xmlfor chapters,image/jpegfor JPGs,text/cssfor stylesheets. - For duplicate IDs: Find items that share an id attribute and rename one. Then update any spine references to that ID.
- For spine order errors: Make sure every idref in the spine matches an actual manifest item ID, and that all reading-order content appears in the spine.
- Repackage and re-validate. Rezip with mimetype first and uncompressed, run validation again, confirm zero OPF errors before uploading.
Pro Tips
- Never rename files inside an EPUB after building. Renaming a chapter file without updating the manifest creates dead references immediately. If you rename, update the OPF at the same time.
- Use
image/jpegnotimage/jpg. The EPUB spec requires the full MIME type. This is the single most common OPF media-type error — entirely preventable. - Clean Word docs before converting. Run your .docx through the Word Cleanup Checker before conversion. It catches double-blank-paragraph patterns that become ghost spacing in EPUB.
- Keep a validated EPUB template. Once you have a clean, error-free EPUB structure, save it as a template and copy it for each new book instead of reconverting from scratch every time.
- Validate after every edit. Any time you manually edit EPUB internals — renaming, adding images, editing OPF — run validation again before uploading. Edits that look correct visually can still break the manifest.
Why These Errors Matter More Than You Think
KDP is relatively forgiving. It accepts a wide range of EPUB quality because it converts your file to its own internal format anyway. Apple Books, Google Play Books, and Kobo are stricter because they render your EPUB directly. The same file can sail through KDP and get rejected everywhere else.
If you're publishing wide — not just Amazon — your EPUB needs to meet a higher standard. Ghost spacing and OPF errors are the two most common reasons wide distribution fails after KDP succeeds. Fixing them once before you upload saves days of back-and-forth with platform support teams.
Frequently Asked Questions
Does ghost spacing affect how my book looks to readers?
Sometimes. On platforms that render it, readers may see extra blank lines between paragraphs or irregular spacing that wasn't in your original manuscript. On platforms that reject the file outright, readers never see it at all — the book simply isn't available to purchase or download.
Can I fix ghost spacing without rebuilding my whole EPUB?
Yes, for mild cases. If only a few chapter files are affected, editing those HTML files manually and repackaging is faster than a full rebuild. For books with heavy ghost spacing throughout — common after Google Docs exports or multiple Calibre conversions — a rebuild from a clean source file is more reliable and often faster than patching hundreds of individual instances across dozens of chapters.
What's the correct media type for JPEG images in an EPUB?
Use image/jpeg — not image/jpg. The EPUB spec requires the full MIME type. image/jpg is not a registered MIME type and will cause validation failures on strict platforms. For reference: PNG images use image/png, SVGs use image/svg+xml, GIFs use image/gif, and WEBP (not recommended for EPUB) uses image/webp but has limited platform support.
Will fixing OPF and ghost spacing errors change how my book looks on Kindle?
No. KDP converts your EPUB to its own format before delivering to Kindle devices, so structural cleanup won't affect the Kindle reading experience. The changes only affect how other platforms — Apple Books, Kobo, Google Play — render your book. Your Kindle readers will see exactly what they saw before.
How do I know if my EPUB passes Apple Books standards before submitting?
Run it through the BookKraft AI EPUB Validator before uploading anywhere. It checks the same structural rules Apple Books uses for validation — ghost spacing, OPF completeness, HTML validity, TOC structure, and image references. A clean validation report means you're ready to submit without risk of rejection. Apple doesn't give you detailed error feedback after the fact, so pre-submission validation is the only reliable way to catch problems before they block your book.