Kindle formatting for web geeks
Amazon’s Kindle, both the standalone version and the iPhone app, make a compelling case for self-published books. The service is quick, free and (mostly) painless. And if you format your books properly, they will look every bit as good as those from traditional publishers.
When I was preparing my short story The Variant for the Kindle, I found a lot of confusing and contradictory information about how to do the formatting — much of it on the official help site. So I’m writing up this quick guide aimed at somebody with roughly my level of coding or design experience.
If you feel comfortable hand-coding a site, you can get a book formatted in 30 minutes or less.
You’ll want to download the source file for The Variant to follow along. If you compare it with the published version as it appears in the Kindle store, you’ll see how it matches up.
(If any of this is over your head, there are several more comprehensive tutorials out there, including Joshua Tallent’s Kindle Formatting.)
So here we go.
1. It’s just a stripped-down HTML document
It’s not XML or anything fancy. Pretend it’s 1995 and you're coding for Netscape Navigator. Think basic.
The Kindle converter will try its best to process a .doc or .pdf, but the results will be always worse than basic HTML. So don't bother. Just give it what it wants. Give it HTML.
Every paragraph is wrapped in standard <p>…</p> tags. I used TextMate's "Wrap Each Selected Line in Open/Close Tag" command, but you may have your own favorite technique.
To force a page break, use <mbp:pagebreak />. There's another way to do it using a style="page-break-before: always;" within an enclosing paragraph tag, but <mbp:pagebreak /> is easier to find when looking through your file.
Links and anchors work just as you'd suspect, which makes it quick to build a table of contents, or link back to a webpage.
In addition, you’ll want to place a special anchor where the text starts: <a name="start"/>. When the book is first opened, it will jump to this spot. This lets you skip over title pages.
2. The less you try to format, the happier you’ll be
You’ll embed a little CSS style sheet in your HTML, but it’s incredibly basic. Use the default typeface. Stick to <em> and <strong>. Let the Kindle do what it wants to do, and you’ll get good results.
The Kindle will default to indenting each paragraph, which looks okay. It will also justify text, which is dandy or unspeakable depending on your preferences. After reading a few dozen books on my Kindle, I’ve come to expect right justification. So will most Kindle readers. But it’s your call. You can override it by setting the text-align property for your paragraph tags.
In books, you often leave a blank line or two between sections of text. It’s best if that’s not indented, so add a CSS rule to do that. Following Joshua Tallent’s lead, I used a CSS class .noind with text indent set to 0, and applied that just to the necessary <p>'s.
I wanted the text to start a little lower on the first page, so I added <p height="40"> </p>. I also put the first sentence in caps.
3. Encode your entities (except for your actual tags)
To be safe, it’s a good idea to convert curly quotes, em dashes and other niceties to their HTML equivalents. Again, TextMate makes this simple: under “Entities,” choose “Convert Character to Entities Excl. Tags.”
That’s it. You’re done with your file. Metadata and other details will be added in through the web interface.
4. If you have a Kindle, mail this file to yourself
When you set up a real (non-iPhone) Kindle, you’re given the option to set up an email address like name@Kindle.com. Anything you send to this address (from a pre-approved address) will get wirelessly schlepped to your Kindle.
So email yourself the HTML file. Check it out on your Kindle to see how it looks. If there's anything you want to change, do it now.
5. Log into the DTP publisher
Amazon’s Digital Text Platform is the home base for your Kindle project. You can log in with your standard Amazon ID. You’ll need to establish details about payment, including bank and ID number in the My Account tab.
You’ll be adding your book in the My Shelf tab. Click “Add a New Item.”
First, you’ll enter product details. You can skip ISBN and any other field that doesn’t apply. (Such as Series Title.)
It’s on this screen that you’ll upload an image for the cover. When preparing your artwork, keep in mind how small it may end up being scaled: down to 35 pixels wide in some lists. For The Variant, I ended up fattening my title type so that it could still be readable at such a tiny size. (I suspect “real” publishers get to submit their artwork in several sizes for optimized display.)
Once you have your product details entered, you’ll upload your HTML file. It’s surprisingly fast. You’ll see a Flash-based preview of your book, which is almost useless except for checking gross errors like missing page breaks. Use it only if you have no access to a real Kindle.
The last tab lets you set a price. Then it’s time to publish.
6. You’re done
Based on the forums, I worried there might be App Store-like delay and approval process before the book would go live. But no. Within an hour, I could navigate to the page on Amazon. Another 45 minutes, and I could download it on my Kindle, just like any other book.
In fact, by the next day, The Variant was the #20 title on Kindle. It’s stayed in the top 100 since.
One thing to remember: the Kindle is U.S.-only. Even with the iPhone app, international users can’t buy your book through Amazon. That’s why it’s important to offer alternatives. For The Variant, I included both .pdf and ePub formats, available through the book’s promotional page.
Amazon makes it surprisingly easy to publish your book, even if the instructions aren’t always straightforward. Anyone with hand-coding chops can get a good-looking book online.

May 26th, 2009 at 9:56 am
Can I download your book if I do not have a kindle?
May 26th, 2009 at 10:17 am
What did you do in that first day to promote your Kindle publication? Besides all the work done beforehand to ensure that you had a great book to publish, to what do you attribute your top 20 position?
May 26th, 2009 at 10:23 am
@Paul Gupta:
Updated to add a paragraph about the promotional page and alternative formats.
@Patrick Dennis:
That’s its own blog post, probably later this week.
May 26th, 2009 at 10:24 am
Minor point regarding your .noind class (and this is coming from a general web coding point of view, not specifically Kindle coding) – usually it’s “better” to name your classes after the semantic function or purpose of the text, rather than after the visual formatting. In other words, a better name for that class might be .intro or .section-intro or .first-paragraph for instance.
The reasoning is this: You might at some point change how you format that particular bit of text. Maybe later on (either on the Kindle or on some other device) you want to keep those section intros indented, but with the font-size bumped up on the whole paragraph, or with a horizontal rule over them, for instance. At that point, “.noind” doesn’t make sense because your styling isn’t dealing with indentation any more. So there’s either a mismatch between the class name and the styling, or you have to go through and change the class name in the html (to “.bigtext” or “.borderedtext” or whatever) if you want to have it relate to the new styling.
By avoiding class names based on visual styling, you don’t have to worry about this.
May 26th, 2009 at 10:30 am
It’s unfortunate that their formatting is so similar, yet not the same as the IDPF’s OEB standard.
An alternative with some benefits over this primitive version is to create a .epub file (See this tutorial on how: http://www.spontaneousderivation.com/2008/12/13/creating-ebooks-an-epub-tutorial/), then convert it to Mobipocket (the actual format Amazon uses) using some open tool like Calibre (http://calibre.kovidgoyal.net/).
You get all the benefits of using the accepted, open standard which includes support for pupular ebook software like Adobe’s Digital Editions and FBReader, but after conversion to Mobipocket, you get what amounts to native support on the Kindle as well, since Amazon’s format is actually Mobipocket with a different file extension.
May 26th, 2009 at 12:30 pm
Thanks for the interesting post, I’ll have to check out the story.
Odd that Amazon doesn’t list any info about the length of the book/story, any idea why they don’t?
And by putting out the source (which is awesome), aren’t you giving people a free version of the story? Or is that just part of it?
May 26th, 2009 at 12:39 pm
As ever, an ungodly mishmash of presentational HTML, inline styles, and faux-codes from John August.
But it works, right?
May 26th, 2009 at 1:54 pm
To ask a stupid question, it seems you can’t just upload a simple pdf file, hmm?
May 26th, 2009 at 2:21 pm
Joshua, your question is answered in the article: “The Kindle converter will try its best to process a .doc or .pdf, but the results will be always worse than basic HTML. “
May 26th, 2009 at 3:04 pm
Joe, you’re certainly welcome to do your own guide to formatting documents for Kindle if you find this one too much “mishmash”.
May 26th, 2009 at 3:17 pm
Well, Kindle is not a compelling option, and it won’t be until Amazon agrees to let me get Kindle books the same way it does gladly ship me kilograms of dead trees across the Atlantic.
You guessed it: I live in Europe. And I can’t get Kindle books for my iPhone Kindle reader.
May 26th, 2009 at 3:47 pm
Thanks John for writing about this, because until now I had no idea that I could self-publish through the kindle store. Now I’m going to look into it, even though sans clout I don’t know how many I’ll be able to sell…
May 26th, 2009 at 4:09 pm
A few things frustrate me about the Kindle – like in one of my books, I have several different fonts used for comedic effect in a couple sequences – those are now dead jokes.
I also deliberately left the entire book without paragraph indentation, and that’s referenced in the book. That now makes no sense, either.
The Kindle heckles me. :(
May 26th, 2009 at 4:38 pm
Thanks for this. I’m a web geek, and I’m just about to self-publish a few short stories on Kindle for a friend. (Is it still self-publishing in that case? I refuse to call myself a vanity press.) The clear steps you outlined are most welcome.
One question: I have no access to a real Kindle. (Just an iPhone.) Is the Flash preview useless because it misrepresents the text, or because it’s difficult to read?
May 26th, 2009 at 4:50 pm
@Joe Clark:
Someone is going to hug you until you love Arial.
@Jean-Denis:
I agree that Kindle should be worldwide. But it’s underlying copyright and contract issues that are the complications, not some terrible conspiracy on Amazon’s part. What are you personally doing to get digital rights unstuck in Europe?
In the meantime, the non-DRM’d ePub version is available for the same price.
@Chris Radcliff:
The preview mostly just looks terrible, and will convince you that there are spacing issues when there aren’t.
May 26th, 2009 at 8:27 pm
John,
Thanks for the reference to my site and for writing a great little guide to the Kindle format. Creating Kindle eBooks is not difficult when you know HTML, and I think you have hit on some of the most important points a developer must know when making an good-looking eBook.
@Cynoclast – ePub is great, but the format of an ePub book does not necessarily translate into a great-looking Mobi/Kindle eBook. Be wary of the formatting produced by automated processes like calibre and mobigen. While they can create a Mobi file from an ePub, the formatting sometimes is less than optimal. You are always better off making the Kindle eBook yourself.
Joshua Tallent eBook Architects Author of Kindle Formatting: The Complete Guide
May 26th, 2009 at 10:51 pm
So… If I was planning on publishing a comic book through Kindle, I’m screwed, right?
Also… How do you pronounce that? Like KIND-LE, as in “kind” or KIN-DLE as in KIMberley?
May 26th, 2009 at 11:30 pm
Really useful tips. Thanks for taking the time to write this up!
May 26th, 2009 at 11:38 pm
Yes, regarding the non availability of Kindle books in Europe, I don’t believe there is a conspiracy from anybody. But I do believe there is some lazyness.
If Amazon has the right to ship dead trees, it should be able to arrange for the right to ship bits.
What am I doing? I am letting my voice heard, and I support initiatives here in Europe which tend to tear down intellectual rights cross national barriers. These efforts have led to the the recent push towards a unique iTunes Store across Europe.
But, and this is a big “but”, our European voices are not loud enough. The best thing to do would to get for some help from you American. If every time somebody publishes something [supportive] about the Kindle, s/he kindly reminds that the picture is darkened by this issue and requests some progress, then that would be the best pressure on Amazon.
May 26th, 2009 at 11:39 pm
Yes, regarding the non availability of Kindle books in Europe, I don’t believe there is a conspiracy from anybody. But I do believe there is some lazyness.
If Amazon has the right to ship dead trees, it should be able to arrange for the right to ship bits.
What am I doing? I am letting my voice heard, and I support initiatives here in Europe which tend to tear down intellectual rights cross national barriers. These efforts have led to the the recent push towards a unique iTunes Store across Europe.
But, and this is a big “but”, our European voices are not loud enough. The best thing to do would to get for some help from you American. If every time somebody publishes something [supportive] about the Kindle, s/he kindly reminds that the picture is darkened by this issue and requests some progress, then that would be the best pressure on Amazon.
May 27th, 2009 at 5:37 am
For anyone else wondering what blue sky the tag fell out of, mbp: is the MobiPocket namespace. A full list of custom tags is at http://www.mobipocket.com/dev/article.asp?BaseFolder=prcgen&File=tagref_mobi.xml (Small nit to pick, then: your file is actually XML even if you think it isn’t.)
For those bemoaning lack of Kindle in Europe, or Amazon DRM, or whatever, try to see the big picture here. There is a reason this product is named Kindle. It’s a prototype. Amazon is showing us the true potential, too long latent, of e-books when distribution is perfectly aligned with consumption. You will have one soon enough.
May 27th, 2009 at 2:18 pm
A few notes n tips:
DRM? publish through DTP and there is none.
The ‘thought break’ can also be accomplished by starting a standard p with a br. This gives you a blank line followed by no indent.
For the ‘height’ notations, it’s probably better to use em lengths rather than pixels. Then if the user changes the font size, the whitespace will remain proportional. And for title pages, I like to use percentage (height=”25%” to space down from the top of the ‘page.’
I’m not sure, but it might be the case that the css can support the ‘page-break-before: always’ tag. This would be a help if all your chapter titles are h2 – then you could just say all h2 headers have the page-break. But I’ve only coded using the mbp:pagebreak because that’s what Amazon is advising.
There’s also the ‘margin’ css attribute, which works on -top, -bottom, and -left, but not on -right.
Blockquote indents from the left but not the right.
May 28th, 2009 at 10:31 am
Thanks for the article, it answers many of my developer questions… also for the interesting analysis on the “real” format behind the extension.
However – I don’t want to dampen your enthusiasm… but is everybody aware that, in contrast to dead trees, eBooks bought from Amazon will be bound to Amazon – forever? I cannot load them to any other device except what Amazon offers me… this is not comparable to to original iTunes DRM situation, where there was always the (official) backdoor of burning CDs… personally, I will not accept this, not even when it is offered in Europe. Some of my “wooden” books here are older than 30 years, don’t depend on any company and I can do with them whatever I want.
May 31st, 2009 at 6:30 pm
@Peter:
I have the same concerns about the Kindle, which is why I don’t own one. I hate to think what owning all my books through a company would mean for how I use them in the future. When someone makes an eReader as nice as the Kindle but free for me to do whatever I please with it, I’ll buy one. In the meantime, I’ll have to settle for reading eBooks in PDF form on my laptop…
June 1st, 2009 at 1:58 pm
Can’t thank you enough for this, especially the sample code file. I’ve been through the Amazon site and it is extremely confusing (very surprising, since their main site excels at usability). Who knew you could explain their required format in just one blog article? Again, many thanks!
June 4th, 2009 at 2:34 pm
@Alan:
For the sake of clarity, please note that Peter’s complaint is that “eBooks bought from Amazon will be bound to Amazon.” A valid concern, certainly… but you then translate this into “all my books,” disregarding the many other sources of Kindle content available online that are NOT dependent on Amazon’s servers or services.
June 10th, 2009 at 2:03 am
Thanks for this. I was wondering about this and had my own theories what would work. Glad to see they were right. However, this means yet another journey back to 1995 as you rightly said!
June 24th, 2009 at 1:43 pm
John,
Why did you capitalize the entire first sentence instead of using the :first-line pseudo-class?
Just a geeky web design teacher wondering.