KaTeX
  • Try
  • Docs
  • v0.16.22
  • Users
  • GitHub

›Usage

Installation

  • Node.js
  • Browser

Usage

  • API
  • CLI
  • Auto-render Extension
  • Extensions & Libraries

Configuring KaTeX

  • Options
  • Security
  • Handling Errors
  • Font

Misc

  • Supported Functions
  • Support Table
  • Common Issues
  • Migration Guide

CLI

KaTeX installed using Node.js package managers comes with a built-in command-line interface (CLI) which can be used to render TeX to HTML. By default, CLI will take the input from standard input.

npx katex

Above uses the npx command to run the locally installed executable after npm install katex. You can also execute with the relative path: ./node_modules/.bin/katex

To use the CLI from local Git clone, you need to build the project first. See Building from Source for more details.

Options

-V, --version

output the version number

-d, --display-mode

Render math in display mode, which puts the math in display style (so \int and \sum are large, for example), and centers the math on the page on its own line.

-F, --format <type>

Determines the markup language of the output.

--leqno

Render display math in leqno style (left-justified tags).

--fleqn

Render display math flush left.

-t, --no-throw-on-error

Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error.

-c, --error-color <color>

A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.

-m, --macro <def>

Define custom macro of the form '\foo:expansion' (use multiple -m arguments for multiple macros).

--min-rule-thickness <size>

Specifies a minimum thickness, in ems, for fraction lines, \sqrt top lines, {array} vertical lines, \hline, \hdashline, \underline, \overline, and the borders of \fbox, \boxed, and \fcolorbox.

-b, --color-is-text-color

Makes \color behave like LaTeX's 2-argument \textcolor, instead of LaTeX's one-argument \color mode change.

-S, --strict

Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.

-T, --trust

Trust the input, enabling all HTML features such as \url.

-s, --max-size <n>

If non-zero, all user-specified sizes, e.g. in \rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large

-e, --max-expand <n>

Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.

-f, --macro-file <path>

Read macro definitions, one per line, from the given file.

-i, --input <path>

Read LaTeX input from the given file.

-o, --output <path>

Write html output to the given file.

-h, --help

Output usage information

← APIAuto-render Extension →
  • Options
    • -V, --version
    • -d, --display-mode
    • -F, --format <type>
    • --leqno
    • --fleqn
    • -t, --no-throw-on-error
    • -c, --error-color <color>
    • -m, --macro <def>
    • --min-rule-thickness <size>
    • -b, --color-is-text-color
    • -S, --strict
    • -T, --trust
    • -s, --max-size <n>
    • -e, --max-expand <n>
    • -f, --macro-file <path>
    • -i, --input <path>
    • -o, --output <path>
    • -h, --help
KaTeX
Docs
InstallationUsageConfigurationMisc
Community
Who is using KaTeX?GitHub DiscussionsStack Overflow
More
ContributorsStar
Khan Academy
Licensed under MIT License
Copyright © 2025 Khan Academy and other contributors