Formatting Your Ebook for Kindle: .Mobi File Format – .OPF File – Part 5

The final player in our .Mobi drama is the .opf file – Open Packaging Format.  It is what is known as a build file.  The Kindlegen program will use the .opf file to call the other files to generate the .mobi file for your ebook.

NOTE:  When you clip & paste into Notepad ++ the quote marks may get changed to so-called smart quotes.  If so, use search function and replace with straight quotes.  

I’m extremely fond of disclaimers, so here’s a big one:  In the same way that I don’t understand every the facet of the car I drive, the word processor I use, or the cell phone service I employ, I don’t know what every line of this code in this file does, exactly.  I could research it and document it here, but I don’t care.  I know that it works, and all I wanted was a reliable recipe for ebooks.

With that said . . . the entire file, which I have named 3LIESforBlog.opf,  is listed below:

<?xml version=”1.0″ encoding=”utf-8″?>

<package unique-identifier=”uid”>


<dc-metadata xmlns:dc=”” xmlns:oebpackage=””>

<dc:Title>3 LIES</dc:Title>


<dc:Identifier id=”uid”>978-0-9832027-0-7</dc:Identifier>

<dc:Creator>Hanson, Helen</dc:Creator>

<dc:Publisher>DOMINO INK</dc:Publisher>

<dc:Subject BASICCode=”FIC031000“>Thriller</dc:Subject>

<dc:Description>At CIA headquarters, a young officer discovers that terrorists may have commandeered their computer systems to launch an unauthorized mission. Elsewhere, conspirators abduct nine people to manipulate the rules of their game. Two disparate ambitions — Clint Masters becomes the reluctant link in the chain of danger.<br />

Ever since Clint’s almost ex-wife dumped him, he bobs along the Massachusetts coast in a sailboat with his black lab for company. He avoids all forms of technology, a counterintuitive effort for the burned-out founder of CatSat Laboratories. Tired of clutching the brass ring, he needed to untether, step off the corporate treadmill, and smell a flower. Fortunately, he met one, a beautiful, unspoiled woman who doesn’t treat him like a commodity. His relationship with Beth offers more promise than his marriage ever did, even if she is on dialysis for her recovering kidneys, until she disappears.<br />

In spite of the evidence, her family refuses to admit she’s in danger. Without routine dialysis, she won’t survive. As Clint realizes that he loves Beth, damn-near ex-wife Paige sashays back into his life with disturbing news.<br />

While the CIA young gun tracks his quarry, Clint enlists the help of two men to find Beth, a blithe Brit named Merlin, and Todd, his playboy partner-in-tech. But Clint must find Beth before her kidneys fail. And before someone unloads a bullet in his head.<br />





<output encoding=”utf-8″ content-type=”text/x-oeb1-document”></output>


<SRP Currency=”USD“>2.99</SRP>





<item id=”item1″ media-type=”text/x-oeb1-document” href=”3LIES.html“></item>

<item id=”toc” media-type=”application/x-dtbncx+xml” href=”toc.ncx”></item>


<spine toc=”toc”>

<itemref idref=”item1″/>




<reference type=”toc” title=”Table of Contents” href=”3LIES.html%23TOC”></reference>

<reference type=”start” title=”Startup Page” href=”3LIES.html%23start”></reference>



For discussion purposes, I’m skipping down to the line that starts with <dc:Title>.  All the code above that point contains document declarations.  If you want more details, check out the Dublin Core site. They defined the standards and that is what the dc in <dc:Title> stands for.  Other than that, I’m not interested.

But from the <dc:Title> on down, you can start making changes to suit your ebook where the information is in bold.  These <dc: tags are highly self-explanatory and contain the following information, in order: my book title, the language in which the book is written, my ISBN, my name, the name of my publishing Co, and the BISAC code and the genre.

I just noticed that the BISAC code is misspelled as BASIC.  It didn’t throw an error, so maybe it doesn’t matter.  Maybe it’s supposed to show somewhere and doesn’t.  Need to investigate, but not today.

11/15/11 UPDATE:  I recently released my new novel DARK POOL.  In the course of generating my new .mobi file, I corrected the misspelling of BISAC (from BASIC), and it worked just fine.  It’s likely that the prior information was ignored when I misspelled it.  I corrected my 3 LIES files as well.  

Look up your BISAC code. It stands for Book Industry Systems Advisory Committee, and I’ll read up on it some time when I can’t sleep.

Next comes the description of my novel, 3 LIES, and the publication date.

Okay, now back to something interesting:


<output encoding=”utf-8″ content-type=”text/x-oeb1-document”></output>


<SRP Currency=”USD”>2.99</SRP>



There are two pieces you want to edit here.  The Embedded Cover is what a reader who buys your book will see when they use the MENU button on the Kindle and then Go To the cover.  You still need to upload a second file at Amazon so that a cover will show up in the Kindle Store.

I uploaded the same file at Amazon that I embedded here.  To use all the real estate on your Kindle screen, you want an image that is exactly 600 pixels wide by 800 pixels tall.  This will fill the frame and won’t add any white space. I use .png files and .jpg files interchangeably, at least for this purpose.

SIDE NOTE ON COVER ART: When you upload later at Amazon, they allow an image that can be as small as 500 pixels or as large as 1280 pixels on a side.  Again I used the same 600 X 800 file.  The actual space Amazon makes available at the sales page is a square.  For instance, if I copy the image for 3 LIES from the sales page to my hard drive, I get a 300 X 300 square with my rectangular cover art nicely centered amid white space.  If I click on the “see larger image” link and download that, it is 500 X 500.  Whatever you upload, they will shrink to meet their specs, but retain the aspect ratio of the original.  Since I wanted mine to look like a book, as opposed to a square CD cover, and didn’t want the image distorted, I used the same file.  If you search on the MP3 downloads available at Amazon, those covers are usually square.

Moving on, the next item after my embedded cover file is the price.  My novel is set at an affordable price of $2.99 USD.  Ta. Da.

This next line <Demo>3LIESSample.prc</Demo> is a bit of a puzzler.  I’m not entirely sure what it does.  I think it becomes the name of the sample file that is used at Amazon.  Kindles can read .prc files. If anyone reading this has better information on this, please leave a comment. I matched the name of my HTML file with this.  For example, if your HTML file is called JAWS.html, then I would name this piece JAWSSample.prc.  Get in the habit of being sensitive to case, epub formatting can be case sensitive.

Finally we get to the manifest, where your other two files are called out for processing.  You just need to make sure your file name matches exactly here.  Again, I don’t recommend spaces in file names:


<item id=”item1″ media-type=”text/x-oeb1-document” href=”3LIES.html“></item>

<item id=”toc” media-type=”application/x-dtbncx+xml” href=”toc.ncx”></item>


I have no idea what this section does.  It somehow defines the table of contents and the start position within the book.  Other than that, well, you know, if it works, I’m good.


<reference type=”toc” title=”Table of Contents” href=”3LIES.html%23TOC”></reference>

<reference type=”start” title=”Startup Page” href=”3LIES.html%23start”></reference>


I do try to investigate the unknowns because I don’t like to share information if I don’t understand it.  But the time involved in spent in figuring it out, isn’t worth it to me.  I don’t do this for hire.  So if the answers don’t come quickly AND the thing works, I move on.  I’ve got a novel to finish.

The only files I didn’t present are the image files.  I’ll post those on Thursday, since they are purely visual.  After that, we do the deed:  generate a .mobi file from all the odd bits.

Comments? Questions?  Answers?  All are welcome.




p.s  My programmer husband has threatened to properly indent the code on these posts . . .

And if this series has made the formatting process easier for you, please consider purchasing one of my novels for yourself or a thriller lover in your life.  Here are the links:

iBookstore – Amazon – Barnes & Noble

Amazon UK – Amazon DE – XinXii

Other Posts in This Series:

Part 1 – .Mobi File v.s .Epub File Format Overview

Part 2 – .Mobi File Format vs .EPub File Format Overview

Part 1 – .Mobi File Format – HTML Component

Part 2 – .Mobi File Format – HTML – Table of Contents

Part 3 – .Mobi File Format – HTML – The Chapters

Part 4 – .Mobi File Format –  Toc.ncx File

Part 6 – .Mobi File Format – Kindlegen Your .Mobi

Kindle Promises Here

Photo by brendan.lally….away


Share on FacebookTweet about this on TwitterShare on Google+Pin on PinterestDigg thisShare on StumbleUponEmail this to someone