MathML to ASCIIMathML Converter
Convert MathML markup to ASCIIMathML notation online. Supports fractions, roots, subscripts, superscripts, Greek letters, and operators.
About
MathML is the W3C standard for encoding mathematical expressions in XML. It is verbose by design: a simple expression like x2 + 1 requires over 40 characters of markup. ASCIIMathML compresses the same semantics into a human-readable shorthand (x^2 + 1) that tools like MathJax can render. Manual conversion is error-prone. A misread <mfrac> nesting level turns ab into ab. This tool parses the MathML DOM tree recursively, maps each presentation element to its ASCIIMathML token, and emits a flat string you can paste directly into any ASCIIMathML-aware renderer. It handles <mfrac>, <msqrt>, <mroot>, <msup>, <msub>, <msubsup>, <mover>, <munder>, <mfenced>, <mtable>, and standard <mo> operator entities. This tool approximates Presentation MathML only. Content MathML (<apply>, <ci>) is outside scope.
Formulas
The converter applies a recursive tree-walking algorithm. Each MathML presentation element maps to an ASCIIMathML token pattern:
momapIdent(content) if tag = mi(convert(child0)) / (convert(child1)) if tag = mfracconvert(child0)^(convert(child1)) if tag = msupjoin(convert(children)) otherwiseWhere mapOp translates Unicode operators to ASCIIMathML tokens (e.g., ร โ xx, รท โ -:, โค โ <=). mapIdent converts Unicode Greek letters to their ASCII names (e.g., ฮฑ โ alpha, ฮฃ โ Sigma). The recursion depth equals the MathML DOM nesting depth, typically under 20 levels.
Reference Data
| MathML Element | Description | ASCIIMathML Output | Example Input |
|---|---|---|---|
<mn> | Number | Literal number | <mn>42</mn> โ 42 |
<mi> | Identifier / variable | Literal or Greek name | <mi>ฮฑ</mi> โ alpha |
<mo> | Operator | ASCII operator symbol | <mo>ร</mo> โ xx |
<mfrac> | Fraction | (a)/(b) | <mfrac><mi>a</mi><mi>b</mi></mfrac> |
<msqrt> | Square root | sqrt(x) | <msqrt><mi>x</mi></msqrt> |
<mroot> | N-th root | root(n)(x) | <mroot><mi>x</mi><mn>3</mn></mroot> |
<msup> | Superscript / power | x^2 | <msup><mi>x</mi><mn>2</mn></msup> |
<msub> | Subscript | x_i | <msub><mi>x</mi><mi>i</mi></msub> |
<msubsup> | Sub + superscript | x_i^2 | <msubsup><mi>x</mi><mi>i</mi><mn>2</mn></msubsup> |
<mover> | Accent above | hat(x), bar(x), vec(x), dot(x) | <mover><mi>x</mi><mo>^</mo></mover> |
<munder> | Script below | underset(b)(a) | <munder><mo>โ</mo><mi>i</mi></munder> |
<munderover> | Scripts above & below | sum_(i=0)^n | <munderover><mo>โ</mo><mrow>...</mrow><mi>n</mi></munderover> |
<mfenced> | Fenced group (parens, brackets) | (a, b) or [a, b] | <mfenced open="[" close="]">...</mfenced> |
<mrow> | Group / row | Concatenation | Transparent wrapper |
<mtext> | Text annotation | text(hello) | <mtext>hello</mtext> |
<mspace> | Whitespace | Single space | <mspace/> |
<mtable> | Matrix / table | [[a,b],[c,d]] | Nested <mtr> / <mtd> |
<mstyle> | Style wrapper | Pass-through | Children processed recursively |
<mpadded> | Spacing wrapper | Pass-through | Children processed recursively |
<menclose> | Enclosure (box, strike) | cancel(x) for updiagonalstrike | <menclose notation="updiagonalstrike">...</menclose> |
<merror> | Error marker | Pass-through content | Children processed recursively |