[OS X TeX] Metapost and TiKZ in a web browser
Jason Alexander
jalex at lse.ac.uk
Sun Sep 13 14:13:13 EDT 2026
Hi all,
I'd thought I would share a project I've been working on which you all might be interested in. It allows you to run MetaPost, TikZ and real TeX
entirely in a web browser, and display images and pages so generated as SVG. That means you can now write web apps which leverage the graphic capabilities of all those tools, for the display.
With Claude's help (really, it's entirely Claude), I compiled four engines from the TeX Live 2025 source to WebAssembly, and linked them into one JavaScript library. The specific engines are MetaPost 2.11, pdfTeX 1.40 and LuaTeX 1.21 (in DVI mode), and dvisvgm 3.4.3. The output produced is byte-identical to TeX Live 2025 on the test material I've tried.
What's new about this project, as opposed to older versions of tikzjax, is that I've tried to implement *all* the features of TiKZ. You can do graph layouts using features specific to LuaTeX, because I've compiled LuaTeX to WebAssembly. And so you can get shading and patterns, with TiKZ, which you couldn't get with tikzjax.
What you can do with it:
- render MetaPost figures to SVG and EPS, with btex ... etex labels typeset by LuaTeX or pdfLaTeX;
- typeset whole LaTeX/TikZ documents to SVG, including graph drawing (via LuaTeX);
- drop diagrams into any page as <script type="text/tikz"> tags, or drive it from a Node/browser API or a small command-line tool.
texmf files (fonts, formats, packages) are fetched lazily, and LuaTeX is downloaded only when a document needs graph drawing.
Here's where you can try it (no install, it all runs client-side). This is hosted on my personal web site, hence the funny URL. There's a GitHub link below, if you want access to the source:
Demos: https://eschatolog.ist/software/mp-tikz-wasm/
Guide: https://eschatolog.ist/software/mp-tikz-wasm/site/guide.html
Editor: https://eschatolog.ist/software/mp-tikz-wasm/site/index.html
Tags: https://eschatolog.ist/software/mp-tikz-wasm/site/tags.html
Source and a prebuilt release (needs neither TeX Live nor Emscripten):
Repo: https://github.com/jmckalex/mp-tikz-wasm
Release: https://github.com/jmckalex/mp-tikz-wasm/releases/latest
tar xzf mp-tikz-wasm-0.1.0.tar.gz && cd mp-tikz-wasm-0.1.0
node serve.mjs 8080 # then open http://localhost:8080/site/
The code is LGPL-3.0-or-later; the bundled TeX Live and engine components keep their own licences (see NOTICE.md). A handful of small source patches were needed, which I'd be glad to send upstream.
I'd be grateful for any testing, bug reports, or comments — especially edge cases in the TeX/MetaPost fidelity — before I announce it to the
wider TeX Live community.
Many thanks,
Jason
More information about the MacOSX-TeX
mailing list