DOCX

Equations and Symbols

Math formulas with the Math API and ruby annotations for East Asian text

Math Formulas

The Math API lets you build mathematical equations using OOXML's Office Math Markup Language (OMML).

Basic Equation

{
  "sections": [
    {
      "children": [
        {
          "paragraph": {
            "children": [
              {
                "math": {
                  "children": [
                    "x",
                    " = ",
                    { "fraction": { "numerator": ["a + b"], "denominator": ["c"] } }
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  ]
}

Complex Equation

{
  "sections": [
    {
      "children": [
        {
          "paragraph": {
            "children": [
              {
                "math": {
                  "children": [
                    "x",
                    " = ",
                    {
                      "sum": {
                        "children": [
                          { "superScript": { "children": ["x"], "superScript": ["2"] } }
                        ],
                        "subScript": ["i=0"],
                        "superScript": ["n"]
                      }
                    }
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  ]
}

Math Components

ComponentDescription
mathRoot equation container
fractionFraction (numerator/denominator)
subScriptSubscript notation
superScriptSuperscript notation
subSuperScriptCombined sub- and superscript
radicalSquare root and nth root
sumSummation (∑)
integralIntegral (∫)
limitLowerLower limit notation
limitUpperUpper limit notation
functionNamed function (e.g. sin, cos)
matrixMatrix (rows and columns)
roundBracketsParentheses grouping
curlyBracketsCurly brace grouping
accentAccents (hat, bar, tilde, etc.)
barOverline/underline bar
eqArrEquation array (aligned equations)
borderBoxBorder box around expression
boxBox with operator emulation
groupChrGroup character (brace, bracket)
phantPhantom (invisible placeholder)

Text in equations

Use a string for plain text or { text: "x" } for styled runs:

In the JSON API, use a string for plain text or { "text": "x" } for styled runs:

{ "math": { "children": ["x", " = ", { "text": "y" }] } }

MathFraction

Numerator and denominator accept MathComponent[] arrays:

JSON:

{ "fraction": { "numerator": ["a + b"], "denominator": ["c"] } }

MathRadical

JSON:

{ "radical": { "children": ["x + y"], "degree": ["3"] } }

MathSubScript / MathSuperScript / MathSubSuperScript

JSON:

{ "subScript": { "children": ["x"], "subScript": ["i"] } }
{ "superScript": { "children": ["x"], "superScript": ["2"] } }
{ "subSuperScript": { "children": ["x"], "subScript": ["i"], "superScript": ["2"] } }

MathSum / MathIntegral

JSON:

{ "sum": { "children": ["x"], "subScript": ["i=0"], "superScript": ["n"] } }
{ "integral": { "children": ["f(x)"], "subScript": ["a"], "superScript": ["b"] } }

MathLimitLower / MathLimitUpper

JSON:

{ "limitLower": { "children": ["lim"], "limit": ["x→0"] } }

MathFunction

JSON:

{ "function": { "name": ["sin"], "children": ["x"] } }

MathMatrix

JSON:

{
  "matrix": {
    "rows": [
      ["a", "b"],
      ["c", "d"]
    ]
  }
}

Brackets

All bracket types produce m:d delimiter elements with different characters:

JSON:

{ "roundBrackets": ["x + y"] }
{ "squareBrackets": ["x"] }
{ "curlyBrackets": ["a", "b"] }
{ "angledBrackets": ["x"] }

Math Accent

Accents (hat, tilde, etc.):

JSON:

{ "accent": { "children": ["x"], "accentCharacter": "^" } }

Math Bar

Overline/underline bars:

JSON:

{ "bar": { "children": ["x"], "type": "top" } }

MathEqArr

Equation array for aligned equations:

JSON:

{
  "eqArr": {
    "rows": [
      ["a", "=", "b + c"],
      ["d", "=", "e + f"]
    ]
  }
}

MathBorderBox

Draw a border box around an expression with configurable borders and strikethroughs:

JSON:

{ "borderBox": { "children": ["a"] } }

Hide the top and bottom borders:

{ "borderBox": { "children": ["b"], "properties": { "hideTop": true, "hideBottom": true } } }

BorderBox Properties

PropertyTypeDescription
hideTopbooleanHide top border
hideBottombooleanHide bottom border
hideLeftbooleanHide left border
hideRightbooleanHide right border
strikeHorizontalbooleanHorizontal strikethrough
strikeVerticalbooleanVertical strikethrough
strikeDiagonalUpbooleanBottom-left to top-right diagonal
strikeDiagonalDownbooleanTop-left to bottom-right diagonal

MathBox

Wrap content in a box, optionally emulating operator behavior:

JSON:

{ "box": { "children": ["x + y"] } }

MathGroupChr

Add a grouping character (brace, bracket, etc.) above or below content:

JSON:

{ "groupChr": { "children": ["a", "b"] } }

MathPhantom

Create invisible placeholders for spacing control:

JSON:

{ "phant": { "children": ["dy"] } }

Advanced Math Properties

Beyond the basic components above, several math elements support a properties block for fine-grained control.

Delimiter Properties

Bracket types (roundBrackets, squareBrackets, curlyBrackets, angledBrackets) accept an object form with children and properties to customize characters, separators, and growth:

{
  roundBrackets: {
    children: [{ text: "a, b, c" }],
    properties: {
      beginCharacter: "(",
      endCharacter: ")",
      separatorCharacter: ",",
      grow: true,
      shape: "centered", // "centered" | "match"
    },
  },
}
PropertyTypeDescription
beginCharacterstringOpening character
endCharacterstringClosing character
separatorCharacterstringElement separator
growbooleanGrow with content height
shape"centered" | "match"Delimiter shape

N-ary Properties (sum / integral)

Control where sub/super limits sit and whether the operator grows:

{
  "sum": {
    "children": [
      {
        "text": "x"
      }
    ],
    "subScript": [
      {
        "text": "i=0"
      }
    ],
    "superScript": [
      {
        "text": "n"
      }
    ],
    "properties": {
      "limitLocation": "undOvr",
      "grow": true
    }
  }
}
PropertyTypeDescription
limitLocation"subSup" | "undOvr"Limit position relative to operator
growbooleanOperator grows with content

Fraction Argument Size

Scale the numerator/denominator font independently:

{
  "fraction": {
    "numerator": [
      {
        "text": "1"
      }
    ],
    "denominator": [
      {
        "text": "2"
      }
    ],
    "numeratorArgumentSize": 80,
    "denominatorArgumentSize": 80
  }
}

Sub/Super Script Alignment

{
  subSuperScript: {
    children: [{ text: "x" }],
    subScript: [{ text: "i" }],
    superScript: [{ text: "2" }],
    alignScript: true,
  },
}

Symbol Runs

Insert Wingdings or other symbol font characters inline:

{
  "sections": [
    {
      "children": [
        {
          "paragraph": {
            "children": [
              "Arrow: ",
              { "symbolRun": { "char": "F021", "symbolFont": "Wingdings" } },
              " check: ",
              { "symbolRun": { "char": "F052", "symbolFont": "Wingdings" } }
            ]
          }
        }
      ]
    }
  ]
}

SymbolRun Options

OptionTypeDescription
charstringHex character code (e.g. "F021")
symbolFontstringFont name (default: "Wingdings")
boldbooleanBold
italicbooleanItalic
colorstringHex color code
sizenumberFont size in points

Ruby Annotations

Ruby annotations provide pronunciation guides for East Asian text (furigana, pinyin, etc.):

{
  "paragraph": {
    "children": [
      {
        "ruby": {
          "properties": {
            "alignment": "center",
            "fontSize": 10,
            "raise": 4,
            "baseFontSize": 18,
            "languageId": "ja-JP"
          },
          "base": { "children": ["漢字"] },
          "text": { "children": ["かんじ"] }
        }
      },
      {
        "ruby": {
          "properties": {
            "alignment": "center",
            "fontSize": 10,
            "raise": 4,
            "baseFontSize": 18,
            "languageId": "zh-CN"
          },
          "base": { "children": ["汉字"] },
          "text": { "children": ["hànzì"] }
        }
      }
    ]
  }
}

Ruby Options

Ruby is an inner child of a run. Its properties, text, and base fields mirror the required w:rubyPr, w:rt, and w:rubyBase elements. Both content fields accept formatted runs.

PropertyTypeDescription
propertiesRubyPropertiesOptionsRequired ruby layout properties
baseRubyContentOptionsFormatted base-text runs
textRubyContentOptionsFormatted annotation-text runs

RubyPropertiesOptions requires alignment, fontSize, raise, baseFontSize, and languageId; dirty is optional.

Copyright © 2026