KaTeX

Fast, self-contained JavaScript library for print-quality LaTeX math rendering on the web.

Library
npm
v0.19.1
20,469 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
93 /100 Excellent
Development Activity 100
Maintenance 96
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
85 /100 Excellent
Architecture 87
Code Quality 88
Innovation 85
Learning Curve 78

KaTeX is a JavaScript library for TeX math rendering that produces print-quality typesetting directly in the browser, with no page reflow and no external dependencies. It ships two entry points — a DOM renderer (katex.render) and a string renderer (katex.renderToString) — so the same parsing and layout engine can be used client-side or in Node.js for server-side rendering of pre-built HTML/MathML. Because it lays out math synchronously against its own font-metrics tables rather than iteratively reflowing the page like MathJax, it renders large documents dramatically faster while remaining consistent across browsers and environments.

What You Get

  • A synchronous DOM renderer (katex.render) and a markup-string renderer (katex.renderToString) for both browser and server-side use
  • An auto-render contrib extension that scans arbitrary page text for math delimiters and renders them in place
  • Extension modules (mhchem for chemistry notation, copy-tex for copy/paste of source LaTeX, render-a11y-string for screen-reader-friendly output)
  • Pre-built font files and CSS so rendered math matches TeX’s print-quality metrics without extra font licensing steps
  • A CLI (katex binary via cli.js) for rendering expressions from the command line or build scripts
  • Both HTML and MathML output in the same render pass, improving accessibility and copy/paste fidelity

Common Use Cases

  • Rendering mathematical notation in documentation sites, blogs, and educational content (e.g. via remark/rehype or MDX plugins)
  • Server-side pre-rendering of math-heavy pages so no client-side JavaScript or reflow is needed at request time
  • Embedding formula input/preview in note-taking apps, textbook platforms, and online course tools
  • Chemical equation rendering via the mhchem contrib module in STEM education tooling

Under The Hood

Architecture — KaTeX’s pipeline is a classic three-stage compiler: src/Lexer.ts tokenizes the input string, src/MacroExpander.ts expands macros against a large built-in macro table (src/macros.ts) plus symbol/function definitions registered via defineFunction/defineSymbol, and src/Parser.ts (~1000 lines) turns the expanded token stream into an AnyParseNode[] parse tree (src/parseTree.ts). From there, src/buildHTML.ts and src/buildMathML.ts independently walk the same parse tree to produce an HTML Span/Anchor DOM-like tree (src/domTree.ts) and a parallel MathML tree, which src/buildTree.ts combines; katex.ts at the repo root is the thin public-facing entry point wiring render/renderToString/generateParseTree around this pipeline and also exposing low-level extension hooks (__defineFunction, __defineMacro, __defineSymbol, __setFontMetrics) for advanced consumers. Tech Stack — Written entirely in TypeScript (66% of the codebase) with a Rollup + Webpack dual build (rollup.config.js, webpack.config.js) producing both CJS and ESM bundles per package.json’s exports map, plus separate bundles for contrib extensions (auto-render, mhchem, copy-tex, mathtex-script-type, render-a11y-string). Runtime dependencies are minimal — only commander for the CLI — keeping the core renderer dependency-free as the README claims; fonts are built via a Perl/Python toolchain in dockers/fonts from TeX’s original metric data. Code Quality — Tests live under test/*-spec.ts (Jest, six top-level spec files covering parsing, MathML, Unicode, error handling, and duplicate-detection, plus a Selenium-driven visual screenshotter suite in test/screenshotter), run via pnpm test:jest, alongside tsc --noEmit type-checking and combined ESLint/Stylelint linting wired into pnpm test. The src/functions/ directory (46 files) cleanly isolates one TeX command family per file with a consistent defineFunction registration pattern, and Husky pre-commit hooks plus semantic-release enforce consistency on every merge. API Design — The public surface is deliberately small (render, renderToString, ParseError, plus underscore-prefixed advanced hooks marked unstable in JSDoc comments), which keeps the common path — call render/renderToString with an expression string and a SettingsOptions object — nearly boilerplate-free, while throwOnError/errorColor settings give callers explicit, well-documented control over invalid-input behavior instead of silent failures.

Used by 65 apps in this directory

Ruby
66%
Other

GitLab

Developer Tools · Devops

24,537

The complete DevOps platform that unifies Git hosting, CI/CD, issue tracking, and security scanning into a single self-hostable application.

View details
87
Repo Health
86
Technical
65
Dependency
Built with
Ruby 66%
JavaScript 20%
Updated 1 weeks ago
TypeScript
91%
Apache 2.0

Helicone

AI Development · Analytics · Monitoring

6,235

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
74
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 91%
Updated 6 days ago
TypeScript
62%
EPL-2.0

Huly Platform

Collaboration · Project Management · Team Chat

27,978

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
62
Dependency
Built with
TypeScript 62%
Svelte 34%
Updated 1 weeks ago
Rust
56%
Other

Jan

AI Assistants

45,052

Run LLMs 100% locally with full privacy, or connect to cloud AI — your machine, your data, your control.

View details
90
Repo Health
81
Technical
65
Dependency
Built with
Rust 56%
TypeScript 40%
Updated 6 days ago
TypeScript
77%
Other

Joplin

Note Taking

56,853

The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.

View details
93
Repo Health
87
Technical
60
Dependency
Built with
TypeScript 77%
JavaScript 14%
Updated 1 weeks ago
Python
51%
AGPL 3.0

Khoj

AI Assistants · Knowledge Management · Productivity

37,802

A self-hostable AI second brain that chats with your documents, searches the web, builds custom agents, and runs entirely on your own LLM.

View details
62
Repo Health
82
Technical
66
Dependency
Built with
Python 51%
TypeScript 36%
Updated 2 months ago
TypeScript
98%
MIT

Kimi Code CLI

AI Agents · AI Code Assistants · Developer Tools

7,983

A single-binary, terminal-native coding agent that reads, edits, and runs code end to end, built by Moonshot AI for Kimi models but pluggable with Anthropic, OpenAI, and Google providers too.

View details
83
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
PHP
55%
AGPL 3.0

Leantime

Collaboration · Productivity · Project Management

11,890

Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira

View details
90
Repo Health
68
Technical
62
Dependency
Built with
PHP 55%
CSS 18%
Blade 14%
Updated 1 weeks ago
Python
53%
AGPL 3.0

LearnHouse

CMS · Learning Management

2,413

Open-source LMS with AI tutoring, real-time collaboration boards, live code execution, and built-in course monetization — self-hosted in minutes.

View details
90
Repo Health
77
Technical
65
Dependency
Built with
Python 53%
TypeScript 45%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers