DOCX

Tables

Create tables with rows, cells, merged cells, borders, and styling

Use the table, cells, and children properties to add structured data to your documents.

Basic Table

{
  "sections": [
    {
      "children": [
        {
          "table": {
            "rows": [
              {
                "cells": [
                  { "children": [{ "paragraph": { "children": [{ "text": "Name" }] } }] },
                  { "children": [{ "paragraph": { "children": [{ "text": "Age" }] } }] }
                ]
              },
              {
                "cells": [
                  { "children": [{ "paragraph": { "children": [{ "text": "Alice" }] } }] },
                  { "children": [{ "paragraph": { "children": [{ "text": "30" }] } }] }
                ]
              }
            ]
          }
        }
      ]
    }
  ]
}

Column Widths

{
  "sections": [
    {
      "children": [
        {
          "table": {
            "columnWidths": [3000, 2000, 2000],
            "rows": [
              {
                "cells": [
                  {
                    "children": [{ "paragraph": { "children": ["Col 1"] } }],
                    "width": { "size": 3000, "type": "dxa" }
                  },
                  {
                    "children": [{ "paragraph": { "children": ["Col 2"] } }],
                    "width": { "size": 2000, "type": "dxa" }
                  },
                  {
                    "children": [{ "paragraph": { "children": ["Col 3"] } }],
                    "width": { "size": 2000, "type": "dxa" }
                  }
                ]
              }
            ]
          }
        }
      ]
    }
  ]
}

Merged Cells

Use verticalMerge to merge cells vertically and columnSpan to merge horizontally:

{
  "sections": [
    {
      "children": [
        {
          "table": {
            "rows": [
              {
                "cells": [
                  {
                    "verticalMerge": "RESTART",
                    "children": [{ "paragraph": { "children": ["Merged (2 rows)"] } }]
                  },
                  { "children": [{ "paragraph": { "children": ["B1"] } }] }
                ]
              },
              {
                "cells": [
                  {
                    "verticalMerge": "CONTINUE",
                    "children": [{ "paragraph": { "children": [] } }]
                  },
                  { "children": [{ "paragraph": { "children": ["B2"] } }] }
                ]
              }
            ]
          }
        }
      ]
    }
  ]
}

Table Borders

{
  "sections": [
    {
      "children": [
        {
          "table": {
            "borders": {
              "top": { "style": "single", "size": 1, "color": "000000" },
              "bottom": { "style": "single", "size": 1, "color": "000000" },
              "left": { "style": "single", "size": 1, "color": "000000" },
              "right": { "style": "single", "size": 1, "color": "000000" },
              "insideHorizontal": { "style": "single", "size": 1, "color": "000000" },
              "insideVertical": { "style": "single", "size": 1, "color": "000000" }
            },
            "rows": [
              {
                "cells": [
                  { "children": [{ "paragraph": { "children": ["A"] } }] },
                  { "children": [{ "paragraph": { "children": ["B"] } }] }
                ]
              },
              {
                "cells": [
                  { "children": [{ "paragraph": { "children": ["C"] } }] },
                  { "children": [{ "paragraph": { "children": ["D"] } }] }
                ]
              }
            ]
          }
        }
      ]
    }
  ]
}

Cell Formatting

Style individual cells with backgrounds, borders, and vertical alignment:

{
  "sections": [
    {
      "children": [
        {
          "table": {
            "rows": [
              {
                "cells": [
                  {
                    "shading": { "fill": "F2F2F2" },
                    "verticalAlign": "center",
                    "borders": {
                      "top": { "style": "single", "size": 1, "color": "CCCCCC" },
                      "bottom": { "style": "single", "size": 1, "color": "CCCCCC" },
                      "left": { "style": "single", "size": 1, "color": "CCCCCC" },
                      "right": { "style": "single", "size": 1, "color": "CCCCCC" }
                    },
                    "children": [{ "paragraph": { "children": ["Styled cell"] } }]
                  }
                ]
              }
            ]
          }
        }
      ]
    }
  ]
}

Table Width Modes

Control how the table occupies the page width:

{
  "sections": [
    {
      "children": [
        {
          "table": {
            "width": { "size": 100, "type": "pct" },
            "rows": [
              {
                "cells": [{ "children": [{ "paragraph": { "children": ["Full width table"] } }] }]
              }
            ]
          }
        }
      ]
    }
  ]
}

Width types:

  • "dxa" — Fixed width in TWIPs
  • "pct" — Percentage of page width (100 = 100%)
  • "auto" — Auto-fit to content

Table Options Reference

OptionTypeDescription
rowsTableRowOptions[]Table rows
widthobjectTable width ({ size, type })
columnWidthsnumber[]Width for each column in TWIPs
bordersobjectBorder definitions for all edges
floatobjectFloating table positioning
Copyright © 2026