TikZ Demo (tikzjax)

April 28, 2026

TikZJax is a small browser runtime that compiles TikZ into SVGs.

Important detail: compilation happens in the browser. What happens in the background is genius: Tikzjax uses a Pascal interpreter written in WASM (Web-Assembly) to run Tex. Tex packages (especcially Tikz and extensions) can be loaded dynamically from the webserver. Tex produces a DVI. Then, a DVI interpreter (dvi2html) written in JS is used to create a SVG.

On this blog I use my custom fork of TikZJax through its React wrapper, @fabsch225/tikzjax-react. The TeX engine runs in a Web Worker, is loaded lazily only when a page actually renders a TikZ block, and compiled diagrams are cached in IndexedDB.

How this is integrated

This blog uses markdown based posts.

Write TikZ inside a fenced code block with language tikz. You do not need to add \usepackage{...} or a document preamble.

Under the hood, the markdown renderer turns that into a <TikZ> component with a preconfigured package set, so you don’t have to import anything yourself:

001import { TikZ, tikz } from '@fabsch225/tikzjax-react';
002import '@fabsch225/tikzjax-react/fonts.css';
003
004<TikZ texPackages={['tikz-cd', 'amssymb']}>{tikz`
005\begin{tikzcd}
006\alpha \arrow[r] & \beta \arrow[r] & \gamma \arrow[r] & \delta \arrow[r] & \epsilon
007\end{tikzcd}
008`}</TikZ>

Diagrams follow the site theme: black is drawn in the text color and white in the page background, so they work in dark mode too.

Another example

This uses custom fonts specific to my fork (1).

Official examples

Some cool stuff.

Footnotes

  1. Hosted on Github (Link) ↩