MathJax 3 · SVG, PNG and MathML

LaTeX Equation Editor

Type LaTeX, see the typeset equation as you go, pick symbols from a palette, and save it as SVG, a 2x or 4x PNG, MathML or a copied image. Paste a list of equations to get a ZIP.

Loading the equation engine (MathJax)…

Equation

Up to 5,000 characters. Packages: AMS, mhchem, physics, braket, cancel, color, mathtools and more; links, \require and file commands are not available.

Examples:

Symbols

Preview

Waiting for the engine…

Style and export

LaTeX Equation Editor

Operator: Abdulla Al Fahad. How tools are built and checked

Word processors and slide tools either squash equations into bitmaps or make you click through a template for every fraction. Writing the equation as LaTeX and exporting it as an image is faster once you know a dozen commands, and the palette on this page covers the rest.

The same source can leave as an SVG that stays sharp at any zoom, a PNG for tools that accept only pictures, or MathML that screen readers can speak.

MathJax is loaded when the page opens, from this site's own files rather than a font or script server, so the equations are typeset in your tab and the fonts are drawn into the SVG as outlines.

Key features

  • Live typesetting with MathJax 3 (Apache-2.0): the packages AMS, newcommand, boldsymbol, braket, cancel, color, enclose, extpfeil, mathtools, mhchem, physics, textmacros, upgreek, verb, gensymb and amscd
  • A palette of 129 symbols and structures in six groups that insert at the caret or wrap the selected text, and MathJax's own error text for a bad command, such as 'Undefined control sequence \foo', instead of a silent blank
  • Display or inline layout, font size from 12 to 160 px, text colour, optional background and 0 to 48 px of padding
  • SVG, PNG at 2x or 4x, MathML, a copied PNG, copied MathML and copied LaTeX, and a batch tab that turns up to 300 lines into a ZIP with a manifest

What the editor typesets and what it refuses

Input is ordinary LaTeX math without the dollar signs or \begin{document}. The Display layout sets the equation as on its own line, with large operators and limits above and below a sum; Inline sets it compactly as in a sentence, so \sum_{k=1}^{n} k is much shorter in inline mode. mhchem's \ce{} writes chemical formulas and reactions, and physics and braket add shortcuts such as \dv{f}{x} and \ket{\psi}.

Commands that would reach outside the equation are refused before typesetting: \href, \url, \require, \class, \cssId, \style, \includegraphics, \input, \include, \write and a few low-level ones. The html, require and autoload packages are not registered, so nothing can pull in a remote extension. The SVG that MathJax returns is also rebuilt from an allowlist of drawing elements and attribute values, and the page reports if anything had to be removed.

How it works

MathJax converts the LaTeX to its internal math tree, then draws it as SVG with every glyph written as an outline, so the file needs no font. The drawing is measured in thousandths of the font size, so a font size of 32 px multiplies the view box by 0.032 to get pixels, and padding is added in the same units.

For PNG, the finished SVG is drawn on a canvas at 2x or 4x. A background colour is part of the SVG, so a transparent equation gives a transparent PNG. The canvas is capped at 8,000 px on a side and 40 million pixels; a larger request is reduced to fit the cap and the reduction is reported.

MathML comes from the same math tree, serialised without any drawing, and carries display="block" when the layout is Display.

Common use cases

  • A teacher builds a slide of 12 physics equations in a batch, takes the 4x PNGs for a projector that cannot read SVG, and keeps the SVGs for the worksheet.
  • A web author pastes the MathML of a formula into a page so that a screen reader reads 'x squared' rather than an image.
  • A chemistry student sets the colour to white on a dark slide background and exports a transparent SVG of \ce{CO2 + H2O <=> H2CO3}.

How to use this tool

  1. Type or paste LaTeX, or press one of the examples.
  2. Insert symbols from the palette where the caret is.
  3. Set layout, font size, colour and background.
  4. Save SVG, PNG or MathML, or copy the image.
  5. For many equations, open Batch to ZIP, paste one per line and choose the files you want.

Example

Quadratic formula example, Display layout, font size 32 px, padding 4 px, transparent background

x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

Files

A 301.7 x 82.8 px SVG; PNG 2x is 603 x 166 px and PNG 4x is 1207 x 331 px. The batch tab with three lines (E = mc^2, an integral and a \ce reaction), SVG on and PNG 2x, writes eq-001 to eq-003 as .svg and .png plus manifest.csv.

Tips for best results

  • Wrap an operator you want upright in \operatorname{} or \mathrm{}: a bare 'max' is set as the product of three italic letters.
  • Use \, for a thin space before dx in an integral, as in \int f(x)\,dx; MathJax does not add it for you.
  • Put words in \text{...}: in math mode MathJax ignores spaces and sets letters in math italic, so a bare phrase runs together.

Common pitfalls

Not every LaTeX package exists in MathJax. TikZ pictures, \usepackage lines and document-level commands are unavailable, and an unsupported command shows as an error rather than being ignored.

The drawing is made of outlines, so the text of an equation cannot be selected or searched in the SVG or PNG; paste the MathML where text must remain readable.

An & outside an alignment or matrix environment is an error in LaTeX and here.

Common errors and how to fix them

Undefined control sequence \foo
The command is not in the loaded packages. Check the spelling, or find the equivalent symbol in the palette.
\href is not available
Links are refused so that an equation cannot open a page. Remove the command and keep its text.
Missing close brace
Count the opening and closing braces; the palette's structure buttons place the caret inside the first pair.

Best practices

  • Export SVG for anything that will be resized, and PNG only where the target tool cannot take SVG.

Frequently asked questions

Why is the SVG a different size from what I expected?

Its pixel size is set by the font size slider, with one em equal to that many pixels, plus the padding on every side. Change the slider and the file scales with it.

Which format should I paste into Word or Google Docs?

Whichever you choose arrives as a picture, not as an equation you can edit, so pick by how the picture will be used. A 4x PNG is accepted by every word processor and by presentation tools that refuse SVG; the SVG is the one to choose where the application can take it, because it stays sharp when the picture is resized. If the equation has to stay editable in the document, type its commands into Word's own equation box (Alt and = on Windows) or Google Docs' Insert, Equation, both of which turn LaTeX-style commands such as \alpha into symbols, and use this page only for tools that accept images alone.

Does the MathML keep the layout?

It keeps the structure, such as fractions and roots, and the display mode. Appearance is up to the reader's MathML renderer, so it will not match the SVG's glyph shapes.