Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm wondering if I can create an EPUB (free and open e-book standard) reader in JavaScript. The basic requirements would be:

  1. Server parts of the EPUB reader from a server API.
  2. Read the EPUB data in JavaScript.
  3. Render it on page.
  4. Provide some extra functionality, like text highlights or page notes.

I have no information about how I could do this. I'm willing to try a prototype project. What are the steps that I could take towards implementing such a thing?

share|improve this question
@FlorianMargaine thanks for the links, I did see those two examples a while ago. I feel that the code of those projects is in prototype mode right now, so trying to reverse engineer it would be really hard. I'm looking for some tips on how I would go about parsing the EPUB content and render it on the page. Specific details or links to where I could find a easy to follow documentation to what epub content looks like and how I would render it on the page. – Vlad Nicula Oct 9 '12 at 12:58
up vote 8 down vote accepted

From your comments, it seems like you are at a very early conceptual stage, and want general guidance... well, that's going to be very difficult to give, since the entire topic is quite large. But in general, what you want to do is:

  1. Read in and parse an epub file using javascript.
  2. Generate HTML which represents the contents (and inline images / SVG / etc).

Well, that's at a very high level, and doesn't help us much. You can break down step 1 by reading up on the epub format itself (e.g.: wikipedia article and general info). Pretty quickly, you should notice that the format uses OCF to package together multiple files, so your first problem will be to create an OCF reader, which also means that you will need to be able to unzip the data in javascript (Florian Margaine's links should give you an idea of how others have solved this problem). At this point, I'd start looking for existing implementations in javascript, because you probably don't want to be implementing all of this from the ground up. This is all before we're even touching the actual contents of the epub file. Once you are past this point, you should be able to read in the actual contents, and attempt to translate them into HTML.

Regarding step 2, I'd start by looking at the various features provided by epub - text, CSS styling, embedded images, etc - and start attacking those one at a time, starting with whatever gives the most return for my time (probably text...).

share|improve this answer
Thank you. This is the kind of starting point I was looking for. – Vlad Nicula Oct 9 '12 at 14:13
I was going to reply but this covers it mostly. Only thing I would add is the link to the actual file spec. – Rig Oct 17 '12 at 23:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.