MathJax 2 vs 3 vs 4: Differences Explained with Live Examples
MathJax 3 is a complete rewrite of MathJax 2, and MathJax 4 builds on version 3 with new fonts and line breaking. This page compares all three versions in one table, then shows the differences you can see for yourself in the live preview.
Open the MathJax 2, 3 and 4 live preview →Quick comparison
| Feature | MathJax 2 | MathJax 3 | MathJax 4 |
|---|---|---|---|
| Status | Legacy, no longer developed | Stable (3.2.2) | Current |
| Configuration | MathJax.Hub.Config() in a text/x-mathjax-config script |
window.MathJax object |
Same as 3 |
| Re-render after page load | MathJax.Hub.Queue(["Typeset", MathJax.Hub]) |
MathJax.typesetPromise() |
Same as 3 |
| CDN file | mathjax@2.7.9/MathJax.js?config=… |
mathjax@3/es5/tex-chtml.js |
mathjax@4/tex-chtml.js |
| Output formats | HTML-CSS, CommonHTML, SVG, NativeMML | CommonHTML, SVG | CommonHTML, SVG |
| Default font | MathJax TeX | MathJax TeX | New Computer Modern (mathjax-newcm) |
| Automatic line breaking | Optional, off by default | Not supported | On for inline math; display math needs displayOverflow: 'linebreak' |
\color{red}{x} + y |
Colours only x |
Colours x + y (works like LaTeX) |
Same as 3 |
| mhchem chemistry | Older version; \pu doesn't work by default |
Current version, loads automatically on \ce or \pu |
Same as 3 |
$...$ inline math |
Off by default | Off by default | Off by default |
\$ for a literal dollar sign |
Off by default (processEscapes) |
On by default | On by default |
| AsciiMath | Included in TeX-MML-AM_* configs |
Must be loaded separately | Must be loaded separately |
| Ignore class | tex2jax_ignore |
mathjax_ignore |
mathjax_ignore |
MathJax 2 vs MathJax 3
This is the big jump. MathJax 3 was rewritten in TypeScript and renders much faster than MathJax 2, but almost everything you write to set it up changes:
- The script URL and the configuration format are different.
- The
MathJax.HubAPI is gone, so code that re-renders math needs updating. - HTML-CSS and NativeMML output were removed; CommonHTML and SVG remain.
- Automatic line breaking was dropped, so long equations overflow instead of wrapping.
\colornow behaves like real LaTeX, which can recolour more than you expect.
The MathJax 2 to 3 migration guide covers each change with before-and-after code.
MathJax 3 vs MathJax 4
MathJax 4 keeps the version 3 configuration and API, so most sites can upgrade by changing the script URL. The visible differences are:
- Fonts: the new default font covers many more characters, and glyph shapes and spacing look slightly different.
-
Line breaking: long inline math wraps at top-level operators such as
+and=, but not inside brackets like(a + b + c)^2. - File paths: there is no
es5/folder in the CDN URL. - Accessibility: speech and keyboard exploration of equations are improved.
See the differences live
Each link opens an example in the live preview, rendered in MathJax 2, 3 and 4 side by side:
- Long equation: MathJax 2 and 3 overflow, while MathJax 4 wraps the inline sum.
-
Chemistry (mhchem):
\pu{123 kJ/mol}fails in MathJax 2 but works in 3 and 4. - Calculus: compare fonts and spacing across all three versions.
Which version should you use?
- New site: use MathJax 4.
- Already on MathJax 3: upgrading to 4 is usually a URL change. Check that the new font and line breaking look right for your content.
- Still on MathJax 2: plan a migration. MathJax 2 still works, but it is no longer developed and is slower than 3 and 4.
Test your own content
The quickest way to find out what changes for your site is to paste real content into the MathJax live preview and compare MathJax 2.7.9, 3.2.2 and 4.1.3 side by side.
Compare your content in MathJax 2, 3 and 4 →