Convert cheap O’Reilly iPhone App Books to .epub

If you own an iPhone or iPod touch, you may have noticed that O’Reilly publishes a lot of its books as cheap iPhone applications:

These book applications go for a couple of bucks, which is very cheap compared to buying them through O’Reilly itself in their digital editions (often $30 or more). The drawback, naturally, is that they are just iPhone applications and you have to read them on the tiny iPhone or iPod screen. You can read them on the iPad, but they look very poor because of the pixel doubling. If you want to read these books on other devices, like a Kindle or iRex Digital Reader you’re out of luck.

Or so I thought.

Just by accident I came across the O’Reilly eBook “tips and tricks” page, which essentially tells you how to extract an HTML version of the book out of the iPhone application. Then you can also read the HTML version on your desktop. That’s nice, but not ideal. What I want is to extract an epub version of the book, so I can read it on the iPad using iBooks, or on any other eBook reader. Luckily, it turns out you can, and it’s not even that hard.

So, even if you do not own an iPhone or iPod touch, there is a cheap way to get digital versions of O’Reilly books this way. Just follow my lead.

Step 1: Buy an O’Reilly iPhone App Book
Simply search for the title in iTunes or search for “O’Reilly” to get the complete list.

Step 2: Find the application on your hard drive
Simply right-click on the app in your application list in iTunes, and choose “Show in Finder” (or whatever the Windows equivalent is):

Step 3: Make a copy of the file (ending with .ipa) to some temporary directory

Step 4: Rename the file to a .zip file and unzip it
Rename your file from something.ipa to and then double-click it to extract it in-place.

This will result in a directory being created next to it:

Step 5: Find the book application inside
Navigate into the resulting directory. Inside it you will find a Payload directory, containing the application. If you’re on windows you can probably simply double-click it to go in, on Mac you have to right-click it and choose “Show package contents”:

Step 6: Zip the contents of the book directory
Inside the .app you will find a book directory, go in there. Then, select all files and compress them into a zip file:

Step 7: Rename the resulting zip file to .epub
The compressing will result in a .zip file, rename it to .epub.

Step 8: Done!
You can now import (simply drag and drop) this .epub file into iTunes, for instance, to synchronize it with your iPad.

And off you go!

Got something to say?
  1. kenboo says:

    very nice!

  2. Guy du Rogue says:

    This is great! Thanks.

  3. h4x3r says:

    Awesome, just awesome! Works great, the code snippets are tiny, as expected, but works great. Thanks heaps! :)

  4. prussell says:

    Excellent – simple and straightforward instructions – works perfectly !

  5. rl says:

    what about non o reilly ipa books? Don’t seem to see a “book” directory…

  6. JHF says:


    Help… I followed all your simple instructions. The only thing I saw vary from your results was that when I compressed the files in the Package, the resulting file was labeled “” not the app name. I changed the name of the file to one that made sense and the extension to .epub. Dragged and dropped into Books section of iTunes, and copied artwork in the icon art as it was missing in the resulting file. It all sync’d to the iPhone and it showed up in the Library (minus the artwork), but as a book with the title on the shelf. When I went to open it I got a error message telling me “Book Format Error – This book cannot be opened because the format is not recognized, or is invalid.” I’m on a new iMac running the latest SnowLeopard and using a new iPhone4 running iOS4.1… So…. what could be going wrong? Any thoughts? I tried it with 2 books. An O’Reilly iPhone dev ipa and a book of Churchill quotes also ipa. Thanks for your help!

  7. Zef Hemel says:

    When you extract the file (which is the expected name by the way, the instructions tell you to rename it to something.epub) what does the resulting directory structure look like?

  8. Jhf says:

    Not sure what you mean by directory at that stage. Once I have renamed the file to name.epub, I am unable to see inside it.

  9. Jhf says:

    OK – sorry I didn’t read your post right. When I extract the archive .zip fie I pretty much get what I started with before compressing – i.e. the original contents of the Payload directory.

  10. Zef Hemel says:

    Maybe it’s easiest if you e-mail me your .epub file, I’ll have a look what went wrong:

  11. Rob Dawson says:

    nice … a script something like this might work:

    !/usr/bin/env ruby

    appPath = “~/Music/iTunes/Mobile\ Applications/” puts unzip #{appPath}#{ARGV[0]} -d ~/tmp/ebook cd ~/tmp/ebook/Payload/*/book;zip #{ARGV[0]}.epub -r *; mv #{ARGV[0]}.epub ~/tmp; rm -rf ~/tmp/ebook

  12. Anonymous says:

    I too have bought oreilly books from itunes and wish to read them on my ipod. I have done your steps but when I transfer or drag and drop or add file to library in intunes and it goes into the the ibooks app it is showing me that it there is file error or format cannnot read. here is the structure of the directory

    2 folders: meta-inf and oebps file: mimetype

    is there anyway I could send you snap shot of the directory so that you provide some assistance to this would greatly appreciate it

  13. Zef Hemel says:

    If you send me your epub file I can have a look:

  14. Peppino says:

    Followed your instructions and it doesn’t work, says it’s not a valid ePub file.

  15. traydaht says:

    Thanks Zef, followed your very clear instructions and can now view my Book with a much more capable viewer.

  16. Jason Haven says:

    To work along with instructions, after you make the .epub file, drag the .epub file from your File navigator (be it Finder on the Mac, or Explorer on windows) .. drag it to the Library/Books node on iTunes. 

    Thank you everybody for your post.  I’ve had to do this to overcome an update glitch that randomly popped up on one of my ebook/app .

  17. Dave says:

    Many thanks for this. All my O’Reilly books have stopped working since the iOS 6 update, pages don’t flow properly, so large parts of most pages cannot be reached. O’Reilly have withdrawn all their books from iTunes, so I guess they will not be fixing the problem. This tip has allowed me to retrieve the books (I can now view them in iBooks).

  18. Esjarrett says:

    Followed the instructions and worked perfectly for me. Thanks a lot.

Trackbacks for this post

  1. cocoa*life - O’Reillyの電子書籍iPhoneアプリから.epubファイルを自作する
  2. Ethan-omics

Comments are closed now.