Math formula converter (LaTeX, MathML, text)

Convert math formulas between LaTeX, MathML and plain text: LaTeX to MathML with a live preview, math expressions to LaTeX, LaTeX to readable text.

loading Math formula converter (LaTeX, MathML, text)
About this tool

Convert math formulas between LaTeX, MathML and plain text

Math is written in different notations depending on where it will be used. LaTeX is the standard for papers, textbooks and many forums and note-taking apps: \frac{a}{b} for a fraction, x^2 for a square. MathML is the W3C markup language for formulas on web pages and in e-books, which browsers, screen readers and word processors can draw and read. Plain text, such as (a + b) / 2 + sqrt(c), is what you type in a spreadsheet, a calculator or a chat. This tool moves a formula between them, in three directions: LaTeX to MathML, math text to LaTeX, and LaTeX to readable text.

LaTeX is parsed by KaTeX, a well-known fast math renderer, and the MathML it produces is indented so you can read it. You can ask for display style (block formulas, like a centred equation) or inline style, and you can keep the original LaTeX inside the MathML as an annotation, which lets other software recover the source. A live preview shows the formula as your browser draws the MathML. Text to LaTeX uses a math expression parser, so it understands function names such as sqrt(), sin(), abs() and the operators + - * / ^ !. LaTeX to text writes the formula as readable symbols (α, ≤, √, superscript digits) or as plain ASCII (alpha, <=, sqrt), your choice.

Everything runs in your browser and the formula is not sent anywhere. There are limits to understand. KaTeX reads the common math commands, not whole LaTeX documents, packages or custom macros defined with large preambles. The conversion to text is a readable rendering, not something that can always be evaluated. And text to LaTeX follows math-expression rules, so it can interpret single letters in surprising ways.

How to convert a formula

  1. Choose the conversion: LaTeX → MathML, Text → LaTeX or LaTeX → text.
  2. Type or paste the formula. Each mode shows an example in the placeholder, such as E = mc^2 + \pi r^2.
  3. For LaTeX to MathML, decide on the display style and whether to keep the LaTeX annotation. The preview is drawn from the MathML itself, so what you see is what a browser will show.
  4. For LaTeX to text, choose Unicode symbols or ASCII names.
  5. Copy the result. If the formula has an error, the tool shows the message from the parser, with the position when it has one, instead of a partial result.

Examples

LaTeX to MathML

E = mc^2 + \pi r^2 becomes a <math> element in which E, m, c and r are identifiers (mi), = and + are operators (mo), the 2 is a number (mn), the squares are msup nodes and π is the identifier π. A fraction \frac{a}{b} + \sqrt{x} gives mfrac and msqrt, and \sum_{i=1}^{n} i gives an msubsup around the symbol ∑.

LaTeX to readable text

\alpha^2 \le \sqrt x         α² ≤ √(x)         alpha^2 <= sqrt(x)
\frac{a+b}{2}                (a+b)/2           (a+b)/2
\sum_{i=1}^{n} i^2           ∑_(i=1)ⁿ i²       sum_(i=1)^n i^2
\int_0^1 x^2 dx              ∫₀¹ x² dx         int_0^1 x^2 dx
x_{n+1}                      xₙ₊₁              x_(n+1)

The first column is the input, the second the Unicode style and the third the ASCII style.

Text to LaTeX

sin(x)/cos(x)        \frac{\sin\left( x\right)}{\cos\left( x\right)}
abs(x) <= 5          \left| x\right|\leq5
5!                   5!

When the parser is picky

(a + b) / 2 + sqrt(c) gives \frac{\left( a+\mathrm{b}\right)}{2}+\sqrt{c}. The letter b was treated as the name of a unit and set upright, which is how this parser reads some single letters. Check the output before you paste it into a paper, and rename variables if needed.

Errors

A formula that is cut short, such as \frac{a, is reported as an unexpected end of input where } was expected. In text mode, a + reports "Unexpected end of expression (char 4)".

Common mistakes

  • Pasting a whole LaTeX document. The tool reads formulas, not \documentclass, packages or environments for text. Paste only the formula, without $ or \[ \] delimiters.
  • Using unsupported commands. KaTeX supports a large set but not everything. An unknown command is reported with its name.
  • Unbalanced braces. Every { needs a }. This is the most common error.
  • Trusting text to LaTeX for single letters. As the example shows, the expression parser may treat letters as units or constants. Use LaTeX directly when the notation matters.
  • Writing multiplication as a space. In math text, write 3*x or 3x; the output may use a tilde or a dot as a spacing hint.
  • Expecting the text version to round trip. The readable text is meant for humans. For example, √(x) is not guaranteed to turn back into the same LaTeX.

Frequently asked questions

Which LaTeX does it understand?

The math commands supported by KaTeX. That covers fractions, roots, sums and integrals, Greek letters, matrices, accents and common symbols. It does not run packages. For special symbols outside math, the HTML entities tool may help.

Why would I want MathML?

Web pages and some document formats can use it directly, and screen readers can read it, without loading a rendering script. Browsers draw it natively.

What does the annotation option do?

It keeps your original LaTeX inside the MathML in an annotation element, so tools that edit formulas can offer the source again.

Can it solve or evaluate the expression?

No, it only converts the notation. To compute a value use the math evaluator.

Is my formula uploaded?

No. KaTeX and the expression parser run locally in your browser.

Report a problem