Formatting An Ebook: A Step-by-Step Guide

You have three options when it comes to formatting an ebook:

  1. Hire a pro
  2. Use a specialized conversion tool
  3. Code the ebook yourself in HTML

This guide to ebook formatting covers the third option – the DIY approach. Here’s an overview of the process:

And if you are seeking information on the other two approaches instead – i.e. hiring a pro or using a tool – check out my free guide to self-publishing which has specific advice and recommendations on that.

how to self-publishing a book free self-publishing guide publish your book for free

warning

ebook formatting format your ebook DIY

I don’t want to dissuade any of the adventurous types wishing to format their own books but a word of caution is appropriate.

Before we get into this, I’m not a professional ebook formatter. If you want a guide to ebook formatting written by a true expert, then check out Guido Henkel’s Zen of eBook Formatting.

This is my own personal process for formatting an ebook, but it does draw heavily on a series of blog posts Guido Henkel wrote in 2010, which you can still find here. I relied on that series for many years as I built my first ebooks. But over time, I started making more and more notes about where I was deviating from the path Guido had charted out, so I thought I’d now publish that here in case it’s useful for anyone.

After clocking up ten years’ experience making my own ebooks, I do a few things differently – but these are predominantly stylistic preferences, or my preferred best practices in terms of ebook layout, or the odd policy change from Amazon here and there.

A Much Bigger Caveat

You will need a fair bit of patience to get through the DIY formatting process. At least the first time. It becomes much less of a head melter after you first format an ebook successfully, but you will be tearing your hair out that first time. Be warned! That said, I actually love formatting my own ebooks; I find it weirdly soothing.

I can fix errors at the drop of a hat, fiddle with my end matter to my heart’s content, and I could even hang out my shingle as an ebook formatter now, if I needed a side-hustle. It’s a useful skill, if you are willing to work through the many frustrations that will accompany your first efforts.

It might take you a whole day to do this the first time. It could even take longer! But after doing this a few times, you’ll be able to whizz through the process in an hour or less. And it doesn’t take much “practice” to reach that point. That first time is a bear though! You have been warned.

Special Warning for Mac Users

This is written for PC peeps. Don’t swear at me; I don’t have a Mac and you actually have a much better piece of software (and an easier time formatting your books).

Check out TextWrangler, and follow along as best you can – I think it will be easy enough, I’m just flagging it in case some steps are slightly different for you. You should have a much easier time of it than the PC army, from what I hear about TextWrangler.

A Specific Note for Children’s Authors

Formatting children’s books are a special challenge andI don’t recommend the below method. Hiring a pro is probably best here but if you want to explore the specialist approach of formatting your own children’s books then check out this post from Darcy Pattinson.

I also recommend this book from Karen Inglis if you want a full guide to publishing and marketing children’s books, and this guest post she wrote for this here site too.

Preparation

ebook formatting for amazon prep

The process of formatting an ebook takes your manuscript and freezes it in place as-is, so make sure it is edited and error free and that you are 100% done fiddling, or else it’s all the way back to the start of this process again — which you really won’t want to do, believe me.

Make sure your front and end matter is exactly how you want it to appear in the e-book – your title/copyright page, any About the Author page, any links to your mailing list, other books, website, social channels, and a place where readers can review your book. All that stuff should be laid out exactly how you want it to appear to readers. Everything bar the table of contents, which we will handle separately (delete it from your manuscript, if you made one yourself).

Calls-to-Action

All these reader requests are known as CTAs – calls-to-action – and they are crucial to an author’s success. I call this Peak Reader Love moment because a reader will never have a more positive opinion of you than the moment they finish your book – presuming you have done your job as a writer.

Which makes it the perfect time to ask them for something, whether that’s a purchase of Book 2, a sign-up, a review, a website visit, or a social follow.

This latter point is really, really important and will have a massive influence on how successful you are. Read Chapter 6 of my free self-publishing guide – Let’s Get Digital – if you haven’t figured out the best way to lay out all your front matter and end matter, in particular those reader requests.

Let me stress, doing this is really important.

Oh, and I use Word for the second phase, so that’s what I’ll refer to below, but any basic word processor should suffice.

Formatting in Word

formatting an ebook in word

The very first thing you should do is save a fresh copy of your finished, proofed, perfectly laid out manuscript.

This is in case you screw anything up, which you probably will the first time. It’s always good to have a master copy of your edited, proofed manuscript in case of any techno-mishaps.

Because I’m paranoid, I have like eight master copies of everything as well as Dropbox, flash drives, and the most elegant solution of all: repeatedly emailing things to myself. Anyway…

Next, it’s time to conduct some find-and-replace maneuvers. If your manuscript is anything like mine, it might have a mix of “smart” and “dumb” quotes, apostrophes, and ellipses. This will convert them all to “smart” ones and will ensure they are all pointing the right way when we convert them to HTML.

This is really easy to do, just input the quotation mark into the Find box, then select Replace, and input the same quotation mark again. Word is clever enough to figure out which way everything should be pointing. Do this for double quotes, single quotes, and ellipses.

Now you have to replace all italics with HTML code. Go back to your Find/Replace box in Word. Click into the Find part, and then hit CTRL-I which will search for every bit of italicized text in your manuscript. In the Replace box, paste in this bit of code – <i>^&</i> – which will wrap all italics with a bit of HTML. We’ll need that later.

Finally, replace any ellipses with this bit of code – &hellip; – and then you are done with the Word part of proceedings.

However, before we get into wrangling the HTML itself, a quick note on why you might want to build two separate editions of your book… or even more than that, depending on your needs.

A Tale Of Two Editions

All ebook retailers use the industry standard EPUB format these days, although until recently Amazon went its own way, as it often does, and required the use of a different format (MOBI – in case you hear reference to it).

This meant that we had to build one edition of our ebooks for Amazon, and another for everywhere else.

A bit of a pain, of course, but self-publishers love turning lemons into lemonade, and authors quickly discovered huge benefits from making custom Amazon editions of their books, particularly from putting links in the back of the book going directly to the Kindle Store, rather than their own website. Any time you reduce the steps a reader has to take, you increase chances of them buying a book, and of course this made it much easier to complete purchases on dedicated ereaders like the standard Kindles – which only have the most rudimentary browsers.

As such, I strongly recommend making two editions of your book – two separate EPUBS – and putting direct Amazon links in the back of the Amazon edition, and generic links to your website in the back of the edition for all non-Amazon retailers. Note: some retailers and distributors will block your books if they have links to Amazon, so the separate edition is crucial here.

It’s worth the extra step, and it might even be worth creating retailer-specific editions for the more important books in your catalogue, like a permafree or series opener.

Now I’ll show you how to do it.

Formatting in Notepad++

ebook formatting notepad++

Here we move from messing around in Word to using a proper HTML editor – it’s called Notepad++ and you can download it free. It’s PC-only, but Mac users have access to an even better piece of software called TextWrangler.

Before we dive into Notepad++ we need to clean out all the hidden gunk in Word because a typical file has all sorts of hidden HTML, which is what can make your ebook go screwy if you just try and upload a Word file to Amazon (please never do that).

Select your entire manuscript in Word, and then copy and paste it into a “dumb” word processor like (regular) Notepad. This will strip out all the hidden HTML code. It will also remove things like italics, which is why we wrapped those sections in code first.

We are going to dump this “clean” manuscript in our HTML editor in a moment, but first we’ll create a “shell” in Notepad++ to apply some styles to this blob o’ text, so save that file in Notepad for now and open Notepad++.

Applying Styles

Once you have formatted your first book, you will have your own “shell” that you can apply to all future books, but you can borrow mine and tweak it as desired so that you style your ebooks the way you like and then just copy that every time you publish a new book.

This is what my shell looks like. I’ll explain everything in a minute. Sorry if this is difficult to read, it’s hard to display HTML code on a webpage because HTML is the code that tells a webpage to do things! I also want to make sure you can copy and paste this and use it yourself.

(Fun trivia: ebooks are essentially a series of HTML pages with a big ‘ol wrapper around them.)

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <head>
    <style type="text/css">
      html, body, div, h1, h2, h3, h4, h5, h6, ul, ol, dl, li, dt, dd, p, pre, table, th, td, tr { margin: 0; padding: 0em; }
p
{
  text-indent: 1em;
  margin-bottom: 0.2em;
}
p.noindent
{
  text-indent: 0em;
  margin-bottom: 0.2em;
}
p.head
{
  text-indent: 0em;
  font-weight: bold;
  font-size: 1.5em;
  margin-bottom: 0.2em;
}
p.head2
{
  text-indent: 0em;
  font-weight: bold;
  font-size: 1.25em;
  margin-bottom: 0.2em;
}
p.chapter
{
  text-indent: 0em;
  font-weight: bold;
  font-size: 2em;
  page-break-before: always;
  margin-top:3em;
  margin-bottom:1em;
}
p.centered
{
  text-indent: 0em;
  text-align: center;
}
span.centered
{
  text-indent: 0em;
  text-align: center;
}
</style>
</head>
<body>

***INSERT BOOK HERE***

</body>

Decoding The Noise

OK. What does any of that mean? I honestly don’t know what all of it means, but I do know that I shouldn’t mess with the first seven lines or Bad Things Happen. The rest of the stuff there is the styles that we totally will play with.

For example this bit of code here is your standard paragraph style:

p
{
text-indent: 1em;
margin-bottom: 0.2em;
}

It just has two elements, one inserting a small indent, and the other creating a small gap underneath the paragraph. You adjust those settings (i.e. 1em and 0.2em) if you like but I think they are good as is.

This next style is for when I want a new paragraph, but don’t want an indent – i.e. after a chapter or scene break or a list. So I called it p.noindent – but you can use whatever you like. You can see it’s the exact same as the paragraph style, just with a text-indent value of 0.

p.noindent
{
  text-indent: 0em;
  margin-bottom: 0.2em;
}

The one after that is to make nice big headings.

p.head
{
  text-indent: 0em;
  font-weight: bold;
  font-size: 1.5em;
  margin-bottom: 0.2em;
}

And then this one is for sub-headings, so a little smaller. You can see I’ve adjusted the font-size value their slightly. You can tweak this if you like.

p.head2
{
  text-indent: 0em;
  font-weight: bold;
  font-size: 1.25em;
  margin-bottom: 0.2em;
}

This style is for a new chapter – this applies a big heading, some space above and below the chapter heading, and also flags that it’s a new chapter for when we auto-compile the table of contents later.

p.chapter
{
  text-indent: 0em;
  font-weight: bold;
  font-size: 2em;
  page-break-before: always;
  margin-top:3em;
  margin-bottom:1em;
}

Finally, all this code is just to center text. Make sure to include all that span code – this is for Apple devices which need specific instructions to center anything for some reason. THANKS STEVE JOBS.

p.centered
{
  text-indent: 0em;
  text-align: center;
}
span.centered
{
  text-indent: 0em;
  text-align: center;
}

How It Looks In Notepad++

Just so you can see it in “action” here is a screenshot of the HTML code from Notepad++ of my book Following – from the start of the <body> tag to the end of the second paragraph of the introduction – just so you can see how we actually apply the styles in the manuscript itself.

ebook formatting format your ebook DIY

Don’t worry about the other bits of code just yet – we’ll get to that. I just wanted to show you an example of what it looks like in Notepad++ in the finished version, when you’re done massaging the text.

Back To The Shell

Let’s return to that “shell” I gave you up top again, this time with a template inserted for your own copyright/title page that you can adjust as needed. I’ve just inserted some square brackets where you need to fill in your own author name, editor, book title and so on.

You can copy and paste this into your blank Notepad++ file so you have your own “shell” to dump your manuscript into.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <head>
    <style type="text/css">
      html, body, div, h1, h2, h3, h4, h5, h6, ul, ol, dl, li, dt, dd, p, pre, table, th, td, tr { margin: 0; padding: 0em; }
p
{
  text-indent: 1em;
  margin-bottom: 0.2em;
}
p.noindent
{
  text-indent: 0em;
  margin-bottom: 0.2em;
}
 p.head
{
  text-indent: 0em;
  font-weight: bold;
  font-size: 1.5em;
  margin-bottom: 0.2em;
}
p.head2
{
  text-indent: 0em;
  font-weight: bold;
  font-size: 1.25em;
  margin-bottom: 0.2em;
}
p.chapter
{
  text-indent: 0em;
  font-weight: bold;
  font-size: 2em;
  page-break-before: always;
  margin-top:3em;
  margin-bottom:1em;
}
p.centered
{
  text-indent: 0em;
  text-align: center;
}
span.centered
{
  text-indent: 0em;
  text-align: center;
}
  </style>
  </head>
  <body>
<p class="centered"><span class="centered"><strong>BOOK TITLE</strong></span></p>
<p class="centered"><span class="centered"><strong><i>Subtitle If You Have One</i></strong></span></p>
<p class="centered"><span class="centered">[Author Name]</span></p>
<p class="centered"><span class="centered">Editor: [Name]</span></p>
<p class="centered"><span class="centered">Cover: [Name]</span></p>
</br>
<p class="centered"><span class="centered">First Edition published [insert date]</span></p>
<p class="centered"><span class="centered">Copyright &copy; 2020 [Author Name]</span></p>
<p class="centered"><span class="centered">[EPUB] Edition</span></p>
<p class="centered"><span class="centered">This ebook is licensed for your personal enjoyment only and may not be re-sold or given away to others. Thank you for respecting the hard work of this author.</span></p>
*** INSERT BOOK HERE ***
</body>

See that bit at the bottom where it says ***INSERT BOOK HERE*** like some kind of demented litbot? This is where you will paste your gunk-free, prepared manuscript which you saved earlier in (regular) Notepad.

Massaging The Text

Now cut and paste the whole manuscript again from (regular) Notepad into Notepad++ right where my “shell” tells you to insert the book – which is inbetween the <body> and </body> tags and below all the copyright guff.

Make sure not to remove these tags! The second one especially is easy to accidentally delete.

With your manuscript pasted in, now it’s time to massage the text into place. I find this part weirdly soothing – like bringing order on a chaotic world. Which makes me sound like Judge Dredd. Hey, if the helmet fits…

Before we go any further, save your Notepad file.

I usually build the Amazon EPUB edition first, make sure it’s error free using a free online checker, and then build the EPUB for the non-Amazon retailers.

So I save this first file as BookNameAmazonEPUB.html and work from there.

At this point, you should open a regular web browser, like Chrome or whatever you use to surf the internet.

Load that BookNameAmazonEPUB.html file, or whatever you have decided to call it, into your browser. It will look like a mess right now, but we are about to massage it all into place and will periodically reload this window to check on our progress.

Keep Checking In Your Browser

For example, here’s what the opening to my book Following looks like when viewed in a web browser – close enough to how it looks on an e-reader, and a useful way to check if you mess anything up as you go.

ebook formatting format your ebook DIY

You can view a few of the styles we defined in our “shell” above – the regular paragraph style, the noindent paragraph style, the chapter style, and the centering style.

Yours won’t look quite so neat… yet. So let’s get on that now.

We are going to run a series of Find-and-Replace operations, just like we did with Word in the second phase, just a lot more of them. Before that though, we need to do two things.

First, hit CTRL-F to bring up the Find-and-Replace menu in Notepad++ and make sure Regular Expressions is ticked. Search for ^(.+)$ and replace with <p>\1</p> to apply our paragraph style to each paragraph.

Second, before we continue with the rest of our Find-and-Replace tags, we must do something quite important: comb the entire text for any stray italics tags or paragraph tags – if we don’t do that now, it can cause huge problems for us later. (BTW, checking the HTML file in your browser window periodically can help all through this entire phase.)

Okay, we are finally ready to bash this into shape with a series of Find-and-Replace operations.

You might have noticed a weird question mark symbol dotted through your manuscript when viewing the HTML file in a web browser. These related to various special characters – like em dashes, quotation marks, apostrophes and so on – and we need to replace them with something called “HTML named entites” so they render properly on a Kindle or an iPhone or a computer or whatever your reader happens to be using.

HTML Named Entities

The most common HTML named entities are copied below, but if you have something else weird, like a character with an accent in their name or something, then check this more complete list. (Note: use right single quote for your apostrophes.)

  NAMED ENTITY
em dash&mdash;
en dash&ndash;
left double quote&ldquo;
right double quote&rdquo;
left single quote&lsquo;
right single quote&rsquo;
copyright symbol©&copy;
ellipse&hellip;
Named entities for formatting an ebook

I’ve included the HTML named entity for ellipses above, but you might remember we already handled that in the Word document earlier – this is because doing a Find-and-Replace on a period symbol can make things go very wrong!

Now need to replace all special characters in your document with HTML named entities like those above. For example, to replace all your em dashes, hit CTRL-F (make sure Regular Expressions is still ticked) and then Find-and-Replace the em dash symbol with &mdash; – and you can just let it Replace All rather than going through them individually.

Repeat that process for all your quotes, apostrophes and any other special characters. Check your work periodically in your web browser.

Once all that is done, it’s time to apply all those paragraph styles – this is where it really starts coming together and it’s fun to view it take shape in a browser as you go (also recommended so that you know where and when you went wrong, as you invariably will at some point).

You might remember we wrapped the entire text of your book in regular paragraph tags. Now we need to go in and change some of those to various styles like chapter, noindent, and so on.

Find-and-Replace

This step takes the longest, but I find it kind of fun. (I do not promise you will find ebook formatting fun!) This is what you need to do:

  • Replace the <p> tag in all chapter headings with <p class="chapter">
  • Where you have a chapter opening or the start of a new scene after a scene break, or anywhere else you want to commence a paragraph without an indent, then replace the <p> tag with <p class="noindent">
  • Any headings, you need replace the <p> tag with <p class="head">
  • And so on for centering, sub-headings, or any styles you added yourself.

Remember to regularly check your work as you go in a browser. This step can take forever the first time you do it, but you can get super fast with practice (for example, I keep my code tags in a little (regular) Notepad doc while doing this and just turbo my way through pasting them where needed).

The reason why it’s important to check in a browser periodically is that if you take a wrong turn you can undo the last step or two and identify the problem. It’s usually a misplaced HTML tag (or a missing one to close what you were doing, like turning off italics, or not closing off a paragraph with a </p> tag).

To give you some reference point, here’s a snapshot of what a bit of Following looks like in Notepad++.

ebook formatting format your ebook DIY

And then here’s that same section previewed in a web browser.

ebook formatting format your ebook DIY

Along the way, you might need to use additional HTML tags. For example <strong> will bold a text – just remember to close it off with </strong> when you want to stop bolding. </br> will give you a carriage return with no text – useful for scene breaks. You don’t need to close that tag off – one of the few standalone tags.

Simple HTML Tips

Keep in mind that you can’t use some HTML tags in an ebook – not everything will work. But you should be covered for most things above. One extra thing you will definitely need is learning how to build a clickable link.

This is how you do a link. This is how you do an image. And this is how you do an image link. That site is wonderful for learning HTML, by the way.

Once you are done massaging everything into place – and that end matter can get a bit fiddly, but persevere until it looks fab – then it’s time to open up Caliber and actually compile your finished ebook so it’s readable by and device. Exciting!

Don’t worry, we haven’t forgotten about the non-Amazon edition – we’ll circle back and build that very quickly once we have finished and tested the Amazon edition.

Formatting in Caliber

formatting an ebook with caliber

Caliber is the tool I recommend for compiling ebooks. You can download it free here for PC or Mac.

While that’s downloading, do one last check of your HTML file for errors – both in Notepad++ and in a web browser for errors. Test all your links, look for any unconverted special characters, and make sure you’re happy with your front and end matter as no changes can be made once you upload your file to Caliber without restarting the whole process from this point onwards.

Now that you have been warned, open Caliber.

Step-by-Step

Click Add Books in the top left and select your finished HTML file.

Click the next button along – Edit Metadata – and fill out all the fields. This will attach some metadata to your book, but I don’t think any of the retailers pay it any attention. I always do it just in case though.

Make sure you use a small file size for the cover. This greatly reduces your overall file size, which means you make more per copy sold on Amazon. This could cost you thousands of dollars over time if you don’t keep your file size low. I use a low-res cover 600px wide, and reduce the file size using this handy free tool. When finished, click OK.

Hit the next button – Convert Books. This is the meat of the ebook formatting process with Caliber. As mentioned, I do the Amazon EPUB first, and then if the file passes validation, I go back and do the non-Amazon EPUB.

Select EPUB from the top-right menu before you do anything else.

Ignore everything except for what I tell you. There are some crazy settings in here and I have no idea what they do… except break everything.

Click Structure Detection in the menu on the left-hand side. At the Chapter Mark dropdown, select NONE. Then, in the field headlined “Insert Page Breaks before…” delete that jumble of text.

Click Table of Contents, the next one down in that left-hand list. In the field marked “Level 1 TOC” insert the following text exactly: //h:p[re:test(@class, "chapter", "i")]

Click EPUB Output and check the box “Preserve Cover Aspect Ratio.”

Finally, click OK in the bottom right-hand corner to compile your ebook! This takes a minute, so scratch your nose.

Click Save To Disk in the top menu bar.

Validating Your EPUB

Open your EPUB, page through it, look for errors – especially check things like the links in the end matter etc. If you don’t have any free app on your computer to read EPUBs, Adobe Digital Editions is both good and free.

Once you have given the file a once over with human eyes, and are happy with the result, you need to give it a once over with the less forgiving eyes of a robot. Validate your EPUB here.

If it returns errors (or if you spot something during your more human review), I’m afraid you will have to open your HTML file in Notepad++, find them and fix them (not always easy, but persist!) and then repeat the above steps to compile the book in Caliber again.

If there are no errors, proceed to compile the the non-Amazon EPUB in exactly the same way as you just did for the Amazon EPUB.

Just remember to take out those links to Amazon! Other retailers can block your book if they detect them – they can be super sensitive to anything Amazon.

That’s it! You have files for all the ebook retailers now… and now you also know ebook formatting!

Testing

ebook formatting - testing

You might have done a lot of testing along the way, but I recommend you do a little more now too, especially important when you are just learning how to format. I like to side-load the Amazon EPUB to my Kindle and page through it. You can also use the various online previewers at the various retailers to check your work.

I recommend being thorough before actually publishing something, and that goes triple for your first rodeo. Once you are happy, upload and enjoy the fruits of your labor!

formatting an ebook - Questions

Pop your questions on formatting an ebook in the box below. I’ll get a ping right away, and answer you once I’m done with this ice sculpture.

David Gaughran

David Gaughran

Born in Ireland, he now lives in a little fishing village in Portugal, although this hasn’t increased the time spent outside. He writes novels under another name, has helped thousands of authors build a readership with his books, blogs, workshops, and courses, and has created marketing campaigns for some of the biggest self-publishers on the planet. Friend to all dogs.