KaTeX: synchronous TeX math rendering for the web
Fast math typesetting for the web.
At a glance
- What is it?
- KaTeX renders LaTeX math to HTML and CSS without touching the page layout, and it can do the same on a server. Here is how the API, the auto-render extension and the browser bundles fit together, and where the supported-function list stops.
- Who is it for?
- Adopt KaTeX when you need math typeset synchronously in the browser or pre-rendered to HTML on a server, and when the expression set stays inside the supported-function list. Do not adopt it if you depend on LaTeX packages or macros that list does not cover, or if you need MathML as the primary output rather than as an accessibility layer.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository received new commits within the last day.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.
Editorial analysis
The problem KaTeX solves: math that does not reflow the page
Math on the web has a layout problem. An expression is not a string of characters in a line box; it is a two-dimensional structure with fractions, radicals, limits and matrices, and the browser has no native model for it. The README describes KaTeX's answer in three claims: it renders synchronously, it does not need to reflow the page, and its layout is based on Donald Knuth's TeX. The first two are the ones that change how a page behaves. A synchronous render means the HTML arrives in the same pass as the rest of the document, so the surrounding text does not jump after the fact.
The audience follows from that. KaTeX is for people who put TeX source in a web page and want it to become HTML and CSS: documentation sites, course material, question-and-answer interfaces, note-taking tools. The README also states that KaTeX produces the same output regardless of browser or environment, which is what makes server-side rendering viable. If you render on the server, the README says there is no need to include the JavaScript on the client, only the CSS and fonts. That is a real architectural choice, not a marketing line: the expression is resolved once, at build or request time, and the browser receives plain HTML.
How the renderer works: TeX source in, HTML and CSS out
KaTeX is self contained. The README states it has no dependencies, and the package layout supports that: the published files include dist/, src/, contrib/ and types/, with no runtime dependencies listed in the package metadata. The two entry points matter here. `katex.render` writes into a DOM element, and `katex.renderToString` returns an HTML string. The README gives the string form for server-side rendering and shows the shape of the result as a span with the class `katex`.
Everything visual comes from the stylesheet and the fonts, not from the JavaScript. That is why the README repeats the instruction to include the CSS and font files in both cases. The renderer emits markup and class names; `katex.min.css` and the font files in the package decide what that markup looks like. Skip them and you get the HTML without the typesetting.
The contrib modules extend the core without changing it. The package exports map lists `./contrib/auto-render`, `./contrib/mhchem`, `./contrib/copy-tex`, `./contrib/mathtex-script-type` and `./contrib/render-a11y-string`, each with separate CommonJS and ESM builds. Auto-render is the one most sites reach for: it walks a text element and replaces math delimiters in place. mhchem handles chemical notation. render-a11y-string is the accessibility path, producing a string representation of an expression. These are opt-in, so a page that only needs `katex.render` does not pull them in.
Installing KaTeX and rendering a first expression
The README offers two routes: a CDN starter template or a self-hosted download from the GitHub releases page. The CDN template pins version 0.18.7 and uses subresource integrity hashes on each script. It also notes that KaTeX requires the HTML5 doctype, and that without it KaTeX may not render properly. That is the kind of constraint worth reading before you copy the snippet into a legacy page.
The template loads three files: the stylesheet, the core script, and the auto-render extension. The core script is deferred to speed up page rendering, and auto-render runs on load against the document body.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-JctiRyLzXCrSoOOzFlSoWLdyzQl7OrrRnhyeBmzB6ZWtcjccUyc8lCQJqIbs3uQX" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-+7Keh381hSkXmXqnjC0JBM/kzsN6TFj+wMKychSLjTvJ8/0ElMde2uKl8i6p6Buj" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-bjyGPfbij8/NDKJhSGZNP/khQVgtHUE5exjm4Ydllo42FwIgYsdLO2lXGmRBf5Mz" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>If you would rather render one expression yourself, the README's API example calls `katex.render` with a TeX string, a target element and an options object. The `throwOnError: false` option makes invalid input render as red TeX source with the error message as hover text instead of throwing.
katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, {
throwOnError: false
});For a server-rendered page, `katex.renderToString` returns the markup instead, and the README shows the result beginning with a span carrying the `katex` class. The same options object applies. In both cases, the stylesheet and fonts still have to be served.
Where KaTeX stops: partial LaTeX support and error handling
The README is direct about the biggest limitation: KaTeX supports much, but not all, of LaTeX and many LaTeX packages, and it points to a list of supported functions rather than claiming full coverage. That list, not the README, is the document you have to check before adopting. A document that compiles under a full TeX distribution can contain macros, packages or environments that KaTeX does not implement, and there is no compatibility mode that makes them work.
The error path is a design decision you have to make explicitly. By default, an invalid expression throws. Passing `throwOnError: false` changes that to rendering the TeX source in red with the error message as hover text. Both behaviours are documented, and neither is a fallback renderer: with the option off, the reader sees the raw source, not a best-effort layout. For user-generated content that is often the right trade, since a visible error beats a broken page. For a build pipeline it usually is not, because a silently red expression can ship to production unnoticed.
The self-contained design has a second cost. Because there are no dependencies and everything is bundled, the CSS and font files are part of your deployment whether you use the CDN or host it yourself. The README states the requirement in both the client and server cases, so a server-side-only setup still needs a static path for the fonts.
KaTeX against MathJax, and against native MathML
The README's own comparison is with a speed test against a competitor, and it frames the difference as synchronous rendering without page reflow. MathJax is the tool people usually weigh against KaTeX, and the split is roughly this: MathJax targets broader LaTeX and MathML coverage, while KaTeX targets a smaller supported set with a synchronous, dependency-free renderer. If your expressions use packages outside the supported list, the coverage difference decides the choice before speed enters the conversation.
The other comparison is MathML, the browser-native markup for mathematics. Using MathML means shipping markup the browser interprets itself, with no JavaScript renderer and no font bundle, but the visual result depends on the browser's own math layout rather than on a TeX-derived engine. KaTeX's accessibility contrib module, render-a11y-string, produces a string representation of an expression, which is a different approach from emitting MathML as the primary output. If your requirement is MathML as the document format, KaTeX is not that tool.
A third option is doing nothing on the client at all and pre-rendering to HTML at build time with `katex.renderToString`. That keeps the browser free of the renderer, and the README explicitly supports it. The trade is that every expression has to be known at build time.
Maintenance, versioning and the MIT licence
The repository is not archived, and the last push was on 2026-09-18. Releases are frequent and versioned: v0.18.7 on 2026-09-06, v0.18.6 on 2026-09-05, v0.18.5 on 2026-08-31. The README carries a semantic-release badge, and the repository has a .releaserc file, so version numbers are produced by that pipeline. The package metadata pins pnpm 11.4.0 as the package manager, and renovate.json is present for dependency updates.
Upgrade cost for consumers is low in one respect and non-trivial in another. The API surface is small: render, renderToString, an options object, and the contrib modules. But the CDN template uses integrity hashes tied to a specific version, and the repository contains an update-sri.js script, which indicates those hashes are regenerated per release. If you pin a version with SRI, upgrading means updating the hashes along with the version strings. If you self-host, you also have to refresh the font files when the stylesheet changes.
The licence is MIT, stated in both the README and the package metadata. MIT is permissive and places few conditions on redistribution, but the repository does not document trademark or attribution requirements beyond the licence text, and this article is not legal advice. If you redistribute the fonts or the built CSS inside a product, read LICENSE in the repository rather than relying on the summary here.
Editorial conclusion
Adopt KaTeX when you need math typeset synchronously in the browser or pre-rendered to HTML on a server, and when the expression set stays inside the supported-function list. Do not adopt it if you depend on LaTeX packages or macros that list does not cover, or if you need MathML as the primary output rather than as an accessibility layer. Before committing, run your own expressions through the supported functions page at katex.org/docs/supported.html and check how your build handles the font files that ship alongside dist/katex.min.css, since the README states that the CSS and fonts must be included in both the client and server rendering paths.
Frequently asked questions
Is KaTeX the same as LaTeX?
No. LaTeX is a document preparation system, while KaTeX is a JavaScript library that renders TeX math on the web. The README states that KaTeX supports much but not all of LaTeX and many LaTeX packages, and points to a list of supported functions.
What functions are supported in KaTeX?
The README does not enumerate them inline; it links to a list of supported functions at katex.org/docs/supported.html. That page is the reference for deciding whether your expressions will render.
How do I install KaTeX?
The README gives two routes: the CDN starter template that loads katex.min.css, katex.min.js and the auto-render extension, or downloading KaTeX from the GitHub releases page and hosting it yourself. The package is also published as katex on npm.
How do I use KaTeX?
Call katex.render with a TeX string and a DOM element, or katex.renderToString to get an HTML string for server-side rendering. The auto-render extension can instead scan text elements and replace math delimiters automatically.
Can I use KaTeX in Notion?
The README and the repository files describe KaTeX as a JavaScript library with a CDN template, an npm package and server-side rendering. They say nothing about Notion integration, so there is no basis here for answering that question.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/katex-katex)