Where did kindlegen go?

I dig around in the guts of Kindle Previewer 3 to search for the kindlegen, a nifty and much-missed command-line utility for creating Kindle books.

Where did kindlegen go?

A couple of days ago, I found myself needing to create book sample in mobi format. To this end, Amazon used to provide a standalone command-utility called kindlegen. Being a command-line app made it easy to integrate with shell script and other utilities, such as pandoc. kindlegen also allowed you to compile Kindle books directly from Scrivener.

Alas, Amazon stopped supporting kindlegen, advising authors instead to upload their books to KDP in the more open Epub format. That advice is fine until you want to side load content onto your Kindle device. I give away content to my newsletter subscribers, and since half of them use Kindles I’d be remiss not to provide it. I also have selfish reasons too, as I’ve thought of buying a Kindle device for testing purposes and for general reading. Ideally Kindle devices would support Epub directly, like Kobo readers, however they do not because…well, actually I have no idea why.

Anyway, for those who still want to produce a mobi file, Amazon recommends you use Kindle Previewer 3, an enormously bloated app that weighs in at close to a gigabyte. I have a copy since it’s a requirement for Scrivener 3 when producing mobi documents on the Mac, however I don’t like using it.

In poking around the guts of Kindle Previewer, I discovered the kindlegen binary in Contents/lib/fc/bin/kindlegen

kindlegen binary
kindlegen binary

So, despite no longer supporting kindlegen as a standalone download (sorry Linux users), it’s still being updated and released for macOS and Microsoft Windows, albeit bundled along with the Kindle Previewer.

To make it easier to use on the command line, I created a symlink to kindlegen in my ~/Applications/bin directory, where I keep the executable shell scripts I write.

$ cd ~/Applications/bin
$ ln -s /Applications/Kindle\ Previewer\ 3.app/Contents/lib/fc/bin/kindlegen kindlegen

I’ve included that directory in my $PATH variable so every utility contained within is available without having to type the full application path.

Now all I need to do is call the command and pass an Epub as an argument.

$ kindlegen ~/Docucments/books/cc/Cadoc-s-Contract-Chpt-2-Chris-Rosser.epub

Concluding thoughts

Naturally, I’d prefer it if Amazon continued to support the kindlegen utility as a standalone download for macOS, Linux and Windows. It would be even better if they supported Epub directly on their devices. However, we do not live in a perfect world, and Amazon is far from a perfect company.

I’ve wholeheartedly embraced Epub, but many of my readers use Kindles and giving them content on their preferred device is obviously a big priority. As noted, I’m also thinking of getting a Kindle (assuming they ever come back in stock in Australia), a thought I’d never entertain if I couldn’t side-load content for testing my books or reading for pleasure.

Then again, maybe I should buy a Kobo…