I'm looking for something equivalent to MathJax, but that does the conversion(s) from MathML or LaTeX to HTML-CSS on the server backend as my site is rendering the page, rather than relying on something client-side like a traditional install of MathJax. Ideally, this would be written in Python, but other languages or commandline tools would be acceptable as well.

There seem to be some out there (latex2html, plastex) but the output quality is much, much lower than what's produced my MathJax.

I've seen some mumblings of node.js + MathJax for this purpose, but with much grumblings from the MathJax maintainers.

  • Hevea is a capable (command line, not server-side) tool and its homepage doesn't do it justice. But I haven't used it for a long time and don't know how it compares to tex4ht, for example. Jun 25, 2011 at 6:11
  • One of the nice things about MathJax is that it doesn't require LaTeX installation. But the client-side parsing is somewhat slow, especially on pages with lots of equations. I had an idea long ago to make a python version of jsmath, but when I took a peek at the source, I found that it's not going to be a trivial work.
    – syockit
    Jan 5, 2014 at 6:19

7 Answers 7


I am working on a similar problem that utilizes the following tools:

  • Python
  • The python-based matplotlib package
  • A server-side installation of LaTeX (via a TeXLive installation)

The configuration has been a bit challenging (still working on getting matplotlib's mathtext rendering functions to recognize the full power of the underlying LaTeX engine), but the output quality is decent (I too still favor MathJax output quality at this point though).

I'm currently using this solution for LaTeX-to-bitmap image conversion, which isn't quite where you wanted to get, but maybe you'll find it to be a workable interim solution?


I wrote the below, then reread the question, and realised that you want to convert to HTML+CSS. I originally thought you meant to MathML or HTML+CSS and answered appropriately. However, the bit about converting from MathML to SVG might be relevant. Also, I'd strongly advise you not to convert from MathML to HTML+CSS. The right way to put maths on the web is with MathML.

(Yes, that's just my opinion ... but it happens to be the right opinion!)

Usually when people talk about "LaTeX to ?ML" then they mean "LaTeX mathematics to ?ML". I'm going to assume that you mean that. If you want a more full conversion then tex4ht is the best bet. However, tex4ht not suitable for a system where the content is generated on demand.

The server-side conversion software that I know of is itexToMML. The input format is a subset of LaTeX mathematical syntax (there's a link of that page of the commands). It can be integrated with Markdown to produce a nice convertor from something a human might type to XHTML+MathML.

The original itexToMML is a C++ library. The current author has developed it in to a ruby extension which is used in the Instiki wiki software (see the nLab for an example). I worked out the correct makefile options to build extensions for PHP, Perl, and Python. I also figured out the correct place to hook it in to PHP Markdown to make that work. I don't know much python so I haven't tried to do the same with python's implementation of markdown but I would really like this to be done, partly because there's a python library for converting MathML to SVG which means that one can serve MathML, SVG, or PNG depending on the browser, thus satisfying everyone (well, probably not everyone). This is what the nForum does.

My version of the itexToMML code is in a BZR repository at http://www.math.ntnu.no/~stacey/code/itexToMML. It's not documented yet - that's on my TODO list. It also needs merging the latest changes from the main itexToMML source - it's a little behind the times.

Oh, and the original itexToMML comes as a ruby gem so it is super easy to install if you use ruby.


You're probably looking for tex4ht. See my answer to this post.


tex4ht does a reasonable job translating latex to html; it does allow you to supply a *.cfg file with css instructions, e.g.

   div.document{font: Verdana,Tahoma,Arial,sans-serif;}
   div.document { margin-left: 80px; margin-right: 80px; 
                  padding-top: 3ex;       
                  padding-bottom: 5ex }  
   div.quote{background: linen;}
   p.quote{background: red;} 

but it does convert equations to images

  • Yeah, I was hoping to get the equations in straight HTML+CSS, and not images. I can fairly easily generate high quality formula equations by just using latex + dvipng
    – slacy
    May 26, 2011 at 19:49

I would believe it is possible to use Mathjax on the server side, here is how.

  1. Write a program that uses Chrome's core to render a HTML page with Mathjax.
  2. Read the output of completely rendered page

You are done.

Of course, the main reason to use MathJax is to be cross browser capable. This allows you to work for only one browser.

  • Wouldn't browser sniffing help avoid compatibility problems anyway?
    – syockit
    Jan 5, 2014 at 6:15
  • Now a reality: github.com/gwicke/mathoid (uses PhantomJS, essentially a headless Chrome). Produces SVG. Could be modified for HTML-CSS but that wouldn't work across browsers... Apr 3, 2014 at 23:57

As of September 2015, there is a MathJax-node project that includes the full MathJax renderer in a format that can be used from Node.js (or, with a little bit of wiring, from any other server language or framework).


KaTeX can render equations on the server side:

  {throwOnError: false}

For example, you could create a PostHTML plugin that calls KaTeX.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .