I needed a script to export long reddit threads (like AMAs) to an ebook so that I can read it on my kindle. I searched for such utility online and found nothing, so I wrote one.

Calibre, a ebook reader software has an utility named ebook-convert, which can convert to/from various ebook formats like epub, mobi, and html.

My script (written for nodejs) uses the reddit API to export a thread into a simple html with nested posts and no special formatting. This can then be converted into ebook format of choice using ebook-convert.

How to use

  1. Install NodeJS and npm
  2. Clone the sainathadapa/reddit2mobi repo
  3. cd reddit2mobi; npm install
  4. Run run_reddit2html.js script.
    • Pass the url of the reddit post as an argument. Optionally, pass the depth (integer) to limit the maximum depth of subtrees in the thread. - Usage: nodejs run_reddit2html.js url depth > out.html
  5. Install Calibre
  6. Convert the generated html into epub/mobi using the ebook-convert from Calibre.
    • Usage: ebook-convert in.html out.mobi

Sample outputs are available in the github repo

Note: Since I wrote the script, reddit2kindle came up, which does this in an easy and a better way.