[![NPM version](https://img.shields.io/npm/v/latex.js.svg?style=plastic)](https://www.npmjs.org/package/latex.js)
[![NPM downloads](https://img.shields.io/npm/dm/latex.js.svg?style=plastic)](https://www.npmjs.org/package/latex.js)
[![CI](https://img.shields.io/github/actions/workflow/status/michael-brade/LaTeX.js/node.js.yml?branch=master&style=plastic)](https://github.com/michael-brade/LaTeX.js/actions/workflows/node.js.yml)
[![Maintainability](https://api.codeclimate.com/v1/badges/f2ab8b70a87a9da55189/maintainability)](https://codeclimate.com/github/michael-brade/LaTeX.js/maintainability)
[![License](https://img.shields.io/github/license/michael-brade/LaTeX.js.svg?style=plastic)](https://github.com/michael-brade/LaTeX.js/blob/master/LICENSE)


# LaTeX to HTML5 translator using a PEG parser

This is a LaTeX to HTML5 translator written in TypeScript, using a PEG parser generated by [peggy](https://peggyjs.org/).
`latex.js` for LaTeX is similar in spirit to `marked` for Markdown.

LaTeX.js tries to be absolutely and uncompromisingly exact and compatible with LaTeX.
The generated HTML is exactly what is meant to be output, down to the last
space. The CSS makes it look like LaTeX output&mdash;except where impossible in principle,
see limitations.

You can play with it here:
[https://latex.js.org/playground.html](https://latex.js.org/playground.html)


## Installation

For CLI usage install it globally (it needs Node.js 22 or newer):

```
npm install -g latex.js
```

For library usage add it to your project:

```
npm install --save-prod latex.js
```

## Documentation

You can find the full documentation on the website: [https://latex.js.org/](https://latex.js.org/)

To work on LaTeX.js itself, see [Development](https://latex.js.org/development.html).

## Alternatives

If you need a LaTeX to HTML translator that also understands TeX to some extent, take a look at:

* [TeX4ht](https://tug.org/applications/tex4ht/mn.html) (TeX)
* [LaTeXML](https://github.com/brucemiller/LaTeXML) (Perl)
* [LaTeX2HTML](https://github.com/latex2html/latex2html) (Perl)
* ~~[HEVEA](http://hevea.inria.fr/) (OCaml)~~
* ~~[plasTeX](https://github.com/tiarno/plastex) (Python)~~

Update: sadly, those last two are nowhere near the quality of LaTeX.js.

There is no such alternative in JavaScript yet, though, which is why I started this project. I want to use it in my
`derby-entities-lib` project.


## License

[![License](https://img.shields.io/github/license/michael-brade/LaTeX.js.svg?style=plastic)](https://github.com/michael-brade/LaTeX.js/blob/master/LICENSE)

Copyright (c) 2015-2026 Michael Brade
