KaTeX renders TeX and LaTeX math expressions into HTML for web pages. It runs in the browser or on Node.js for server-side HTML output without external dependencies.
Overview
KaTeX converts mathematical notation written in TeX syntax into formatted HTML for websites and applications. Its layout follows Donald Knuth’s TeX rules aimed at print-quality math in the browser.
The JavaScript API can render directly into a DOM element with katex.render or return an HTML string with katex.renderToString for server-side generation. Callers include bundled CSS and font files; client-side JS is optional when all math is pre-rendered on the server.
An auto-render extension can scan pages and typeset delimited expressions based on documented configuration options. Invalid input can surface as visible TeX with error styling when throwOnError is disabled.
The library supports a large subset of LaTeX commands and packages, with a published supported-function list. Major desktop browsers are supported, and pre-rendering workflows yield consistent output across environments.
Key features
- TeX and LaTeX math rendering
- Synchronous in-browser layout
- Node.js HTML string output
- Dependency-free client bundle
- Auto-render page extension
- Configurable error display
- Self-hostable font and CSS assets
- Broad browser compatibility
Use cases
- Math notation on documentation sites
- Server-pre-rendered formula HTML
- Educational web articles with equations
- Inline and display math in apps