MathJSON

The MathJSON format is a lightweight data interchange format for mathematical notation.

Math MathJSON
\[\frac{n}{1+n}\] ["Divide", "n", ["Add", 1, "n"]]
\[e^{\imaginaryI \pi }+1=0\] ["Equal", ["Add", ["Power", "ExponentialE", ["Multiply", "Pi", "ImaginaryI"], 1]], 0]
\[\sin^{-1}^\prime(x)\] [["Derivative", 1, ["InverseFunction", "Sin"]], "x"]

The MathJSON library for Typescript/Javascript can be used to manipulate MathJSON expressions.

import { parse, serialize } from 'math-json';

console.log(parse('\\frac{\\pi}{2}'));
// ➔ ["Divide", "Pi", 2]

console.log(serialize([["InverseFunction", "Sin"], "x"));
// ➔ \sin^{-1}x

Next