-1
Daily
+24
Weekly
+64
Monthly
20,520
stars
1,348
forks
284
watchers
2,328
prs
1,695
issues
128
releases
README
!katex.min.js size
KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web.
Fast: KaTeX renders its math synchronously and doesn't need to reflow the page. See how it compares to a competitor in this speed test.
Print quality: KaTeX's layout is based on Donald Knuth's TeX, the gold standard for math typesetting.
Self contained: KaTeX has no dependencies and can easily be bundled with your website resources.
Server side rendering: KaTeX produces the same output regardless of browser or environment, so you can pre-render expressions using Node.js and send them as plain HTML.
KaTeX is compatible with all major browsers, including Chrome, Safari, Firefox, Opera, and Edge.
KaTeX supports much (but not all) of LaTeX and many LaTeX packages. See the list of supported functions.
Try out KaTeX on the demo page!
Getting started
Starter template
html
...
You can also download KaTeX and host it yourself.
For details on how to configure auto-render extension, refer to the documentation.
API
Call katex.render to render a TeX expression directly into a DOM element.
For example:
js
katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, {
throwOnError: false
});
Call katex.renderToString to generate an HTML string of the rendered math,
e.g., for server-side rendering. For example:
js
var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", {
throwOnError: false
});
// '...'
Make sure to include the CSS and font files in both cases.
If you are doing all rendering on the server, there is no need to include the
JavaScript on the client.
The examples above use the throwOnError: false option, which renders invalid
inputs as the TeX source code in red (by default), with the error message as
hover text. For other available options, see the
API documentation,
options documentation, and
handling errors documentation.
Demo and Documentation
Learn more about using KaTeX on the website!
Contributors
Code Contributors
This project exists thanks to all the people who contribute code. If you'd like to help, see our guide to contributing code.
Financial Contributors
Become a financial contributor and help us sustain our community.
Individuals
Organizations
Support this project with your organization. Your logo will show up here with a link to your website.
License
KaTeX is licensed under the MIT License.Top issues
#587Discussion: horizontal metrics61 comments · 2016-12-17#2194Reduce redundant DOM elements39 comments · 2020-02-01#2003Support \eqref and \label33 comments · 2019-06-15#820VoiceOver screenreader can't read KaTeX's hidden MathML33 comments · 2017-08-25#376Create an intermediate representation that can be used to render to multiple targets31 comments · 2015-10-30#1775\frac-lines is not displayed in the WebKitGTK+28 comments · 2018-11-04#800update buildHTML to output HAST28 comments · 2017-08-17#2491Zoom levels stopping KaTeX/LaTeX fractions rendering correctly 27 comments · 2020-09-10
Discussions
#4332Are AI-assisted contributions allowed?0 comments · 2026-11-15#4316Primary School Maths Typesting (Question)2 comments · 2026-10-21#4305NOS: working notes with KaTeX math, next to the HTML pages you share0 comments · 2026-10-12#4274KaTeX math can now be copied directly into Microsoft Word0 comments · 2026-08-26#4269Does it matter that some descent metrics are wrong in fontMetricsData.js?0 comments · 2026-08-21#4266build katex equations with transclusion0 comments · 2026-08-15#4120Best way to validate if a string is valid LaTeX?1 comments · 2025-12-20#4118Is there a way to reconstruct LaTeX source from rendered .katex-html or sanitized MathML?1 comments · 2025-11-24
Latest release
v0.19.1 v0.19.1 2026-10-230.19.1 (2026-10-23) Bug Fixes allow percent sign in raw argument type (4307) (6971e5c)