Fork me on GitHub


AsciiMath is an easy-to-write markup language for mathematics.
Try it out in the interactive renderer:

`sum_(i=1)^n i^3=((n(n+1))/2)^2`

Getting Started

In order to get started you have two options:

  1. Use MathJax to render your formulas. MathJax is a full fledged open source JavaScript display engine for mathematics and works in all browsers.
    This is the recommended approach!

    Get started by loading the default AsciiMath configuration:

    <script src=""></script>

    Text in you HTML enclosed in ` (backticks) will now get rendered as a math formula. The math delimiters can also be customized. Check out the MathJax website for more information!

  2. Load the AsciiMath javascript file (get it on GitHub) in either the head or the body tag of your website like this:

    <script src="ASCIIMathML.js"></script>

    This file contains JavaScript to convert AsciiMath notation and (some) LaTeX to Presentation MathML. The conversion is done while the HTML page loads.

    Attention: Currently this only works in Firefox 3+ and Safari 5.1+

    As HTML5 including MathML has currently become an official recommendation, the remaining browsers are likely to follow with first implementations soon!


Operation symbols
Type See
+ `+`
- `-`
* `*`
** `**`
*** `***`
// `//`
\\ `\\`
xx `xx`
-: `-:`
@ `@`
o+ `o+`
ox `ox`
o. `o.`
sum `sum`
prod `prod`
^^ `^^`
^^^ `^^^`
vv `vv`
vvv `vvv`
nn `nn`
nnn `nnn`
uu `uu`
uuu `uuu`
Miscellaneous symbols
Type See
int `int`
oint `oint`
del `del`
grad `grad`
+- `+-`
O/ `O/`
oo `oo`
aleph `aleph`
/_ `/_`
:. `:.`
|...| `|...|`
|cdots| `|cdots|`
vdots `vdots`
ddots `ddots`
|\ | `|\ |`
|quad| `|quad|`
diamond `diamond`
square `square`
|__ `|__`
__| `__|`
|~ `|~`
~| `~|`
Relation symbols
Type See
= `=`
!= `!=`
< `<`
> `>`
<= `<=`
>= `>=`
-< `-<`
>- `>-`
in `in`
!in `!in`
sub `sub`
sup `sup`
sube `sube`
supe `supe`
-= `-=`
~= `~=`
~~ `~~`
prop `prop`
Greek Letters
Type See Type See
alpha `alpha`
beta `beta`
chi `chi`
delta `delta` Delta `Delta`
epsilon `epsilon`
varepsilon `varepsilon`
eta `eta`
gamma `gamma` Gamma `Gamma`
iota `iota`
kappa `kappa`
lambda `lambda` Lambda `Lambda`
mu `mu`
nu `nu`
omega `omega` Omega `Omega`
phi `phi` Phi `Phi`
varphi `varphi`
pi `pi` Pi `Pi`
psi `psi` Psi `Psi`
rho `rho`
sigma `sigma` Sigma `Sigma`
tau `tau`
theta `theta` Theta `Theta`
vartheta `vartheta`
upsilon `upsilon`
xi `xi` Xi `Xi`
zeta `zeta`
Logical symbols
Type See
and `and`
or `or`
not `not`
=> `=>`
if `if`
iff `iff`
_|_ `_|_`
|-- `|--`
|== `|==`
Grouping brackets
Type See
( `(`
) `)`
[ `[`
] `]`
{ `{`
} `}`
(: `(:`
:) `:)`
{: `{:`
:} `:}`
Type See
uarr `uarr`
darr `darr`
rarr `rarr`
-> `->`
|-> `|->`
larr `larr`
harr `harr`
rArr `rArr`
lArr `lArr`
hArr `hArr`
Type See
hat x `hat x`
bar x `bar x`
ul x `ul x`
vec x `vec x`
dot x `dot x`
ddot x `ddot x`
Font commands
Type See
bb "AaBbCc" `bb "AaBbCc"`
bbb "AaBbCc" `bbb "AaBbCc"`
cc "AaBbCc" `cc "AaBbCc"`
tt "AaBbCc" `tt "AaBbCc"`
fr "AaBbCc" `fr "AaBbCc"`
sf "AaBbCc" `sf "AaBbCc"`

Special Cases

Matrices: [[a,b],[c,d]] yields to `[[a,b],[c,d]]`

Column vectors: ((a,b),(c,d)) yields to `((a,b),(c,d))`

Complex subscripts: lim_(x->oo) yields to `lim_(x->oo)`

Subscripts must come before superscripts: int_0^1 f(x)dx yields to `int_0^1 f(x)dx`

Attention: Always try to surround the > and < characters with spaces so that the html parser does not confuse it with an opening or closing tag!

Standard Functions

sin, cos, tan, csc, sec, cot, sinh, cosh, tanh, log, ln, det, dim, lim, mod, gcd, lcm, min, max

The Grammar

Here is a definition of the grammar used to parse AsciiMath expressions. In the Backus-Naur form given below, the letter on the left of the ::= represents a category of symbols that could be one of the possible sequences of symbols listed on the right. The vertical bar | separates the alternatives.

c ::= [A-z] | numbers | greek letters | other constant symbols (see below)
u ::= 'sqrt' | 'text' | 'bb' |     other unary symbols for font commands
b ::= 'frac' | 'root' | 'stackrel' binary symbols
l ::= ( | [ | { | (: | {:          left brackets
r ::= ) | ] | } | :) | :}          right brackets
S ::= c | lEr | uS | bSS | "any"   simple expression
E ::= SE | S/S | S_S | S^S | S_S^S expression (fraction, sub-, super-, subsuperscript)