# @md2docx/table

> Plugin to convert Markdown tables (MDAST) to DOCX with support for rich formatting and seamless integration into mdast2docx.

Latest version **0.1.3** (published 2026-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @md2docx/table
pnpm add @md2docx/table
yarn add @md2docx/table
bun add @md2docx/table
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2026-10-22 |
| First published | 2025-03-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| Author | Mayank Kumar Chaudhari |
| Maintainers | mayank1513 |
| Keywords | table-plugin, tables, mdast-tables, markdown-tables, docx-tables, markdown-to-docx, mdast-to-docx, mdast, markdown, plugin, converter, docx, ms-word, export, document-generator, document-generation, text-processing, remark, unified, typescript, open-source, customizable, seamless-integration, modern, web-development, automation, google-sheets, rich-text, compatibility, progressive, cutting-edge, frontend, generative-ai, md2docx, mdast2docx, m2d, mayank1513 |

## Links

- npm: https://www.npmjs.com/package/@md2docx/table
- Repository: https://github.com/md2docx/md2docx
- Homepage: https://github.com/md2docx/md2docx/blob/main/packages/table/README.md
- Issues: https://github.com/md2docx/md2docx/issues
- Funding: https://github.com/sponsors/md2docx
- npm.io page: https://npm.io/package/@md2docx/table

## Dependencies (1)

- [@m2d/table](https://npm.io/package/@m2d/table.md) 0.1.3

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 0.1.3 (latest) — 2026-10-22
- 0.1.1 — 2025-09-22
- 0.1.0 — 2025-09-14
- 0.0.7 — 2025-06-24
- 0.0.6 — 2025-05-29
- 0.0.5 — 2025-05-20
- 0.0.4 — 2025-04-08
- 0.0.3 — 2025-03-26

## README

# @m2d/table <img src="https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png" style="height: 40px"/>

<p className="flex gap-2">
  <a href="https://github.com/md2docx/md2docx/actions/workflows/ci.yml" rel="noopener noreferrer">
    <img alt="CI" src="https://github.com/md2docx/md2docx/actions/workflows/ci.yml/badge.svg" />
  </a>
  <a href="https://codecov.io/gh/md2docx/md2docx/tree/main/packages/@m2d/table" rel="noopener noreferrer">
    <img alt="codecov" src="https://codecov.io/gh/md2docx/md2docx/graph/badge.svg?flag=@m2d/table" />
  </a> 
  <a href="https://npmjs.com/package/@m2d/table" rel="noopener noreferrer">
    <img alt="npm version" src="https://img.shields.io/npm/v/@m2d/table" />
  </a>
  <a href="https://npmjs.com/package/@m2d/table" rel="noopener noreferrer">
    <img alt="npm downloads" src="https://img.shields.io/npm/d18m/@m2d/table" />
  </a>
  <a href="https://npmjs.com/package/@m2d/table" rel="noopener noreferrer">
    <img alt="npm bundle size" src="https://img.shields.io/bundlephobia/minzip/@m2d/table" />
  </a>
  <img alt="license" src="https://img.shields.io/npm/l/@m2d/table" />
</p>

> @m2d/table: Markdown Table formatting plugin for `@m2d/core`. Renders rich, customizable Word tables with column alignment, borders, cell shading, and repeating headers.

---

## ✨ Features

- 📊 **Native Word Tables**: Converts Markdown GFM tables into clean `docx.Table` elements with authentic Word OpenXML borders and paddings.
- 🎯 **Automatic Column Alignment**: Honors Markdown column alignments (`left`, `center`, `right`) with fallback defaults.
- 🎨 **Rich Cell Styling**: Style headers and data cells with background fills (`shading`), custom typography (fonts, sizes, colors), and paragraph spacing via the `data` option.
- 📄 **Multi-Page Header Repetition**: Automatically repeats header rows across page breaks (`tableHeader: true`).
- 🧱 **Block Content in Cells**: Seamlessly accommodates nested paragraphs, lists, code snippets, and blockquotes inside table cells (ideal when paired with `@m2d/html`).

---

## 📦 Installation


> [!TIP]
> **This package (@md2docx/table) is an official alias of [@m2d/table](https://npmjs.com/package/@m2d/table).**

<details>
<summary>Why does this exist?</summary>

We provide this package to offer shorter import paths and improved discoverability. While both packages provide identical functionality, **@m2d/table** is the primary source of truth.
</details>

<details>
<summary>Which one should I use?</summary>

* **Use @md2docx/table** if you prefer the shorter name or specific branding or ESM Only.
* **Use @m2d/table** for the most stable long-term reference and standard alignment.

| Feature | @m2d/table | @md2docx/table |
| --- | --- | --- |
| **Source Code** | ✅ Primary | 🔗 Proxy |
| **Updates** | Immediate | Synchronized (Immediately) |
| **Bundle Size** | 100% | 100% (Zero overhead) |
| **Format** | ESM + CJS | ESM Only |
| **Maintenance** | ✅ Primary | 🔗 Proxy (inherits) |
| **Security** | ✅ Primary | 🔗 Proxy (inherits) |

</details>

<details>
<summary>Maintenance & Support</summary>

> **Security:** Security audits are performed on the canonical package; this alias inherits all security patches automatically.
</details>

---



```bash
$ pnpm add @m2d/table @m2d/core docx
```

**_or_**

```bash
$ npm install @m2d/table @m2d/core docx
```

**_or_**

```bash
$ yarn add @m2d/table @m2d/core docx
```

---

## 🚀 Quick Start

```typescript
import { toDocx } from "@m2d/core";
import { tablePlugin } from "@m2d/table";
import remarkGfm from "remark-gfm";
import remarkParse from "remark-parse";
import { unified } from "unified";

const markdown = `
# Quarterly Summary

| Quarter | Revenue | Growth | Status |
| :------ | :-----: | -----: | :----: |
| Q1      | $1.2M   | +12%   | Active |
| Q2      | $1.5M   | +25%   | Active |
| Q3      | $1.8M   | +20%   | Active |
`;

const mdast = unified().use(remarkParse).use(remarkGfm).parse(markdown);

const docxBlob = await toDocx(mdast, {}, {
  plugins: [tablePlugin()],
});
```

---

## ⚙️ Plugin Options

```typescript
import { AlignmentType, ShadingType, VerticalAlignTable } from "docx";

tablePlugin({
  // Table level properties (width, margins, borders)
  tableProps: { ... },

  // General row properties
  rowProps: { cantSplit: true },

  // First row (header) properties
  firstRowProps: { tableHeader: true },

  // Header cell styling
  firstRowCellProps: {
    shading: { type: ShadingType.SOLID, fill: "1E293B" },
    data: { bold: true, color: "FFFFFF", alignment: AlignmentType.CENTER },
  },

  // Body cell styling
  cellProps: {
    data: { size: 20, font: "Segoe UI" },
  },

  // Alignment configuration
  alignments: {
    preferMdData: true,
    defaultHorizontalAlign: AlignmentType.LEFT,
    defaultVerticalAlign: VerticalAlignTable.CENTER,
  },
});
```

---

## 📚 Deep Dive Guides

- 🎨 **[Table Styling & Layout Guide](./docs/table-styling-and-layout.mdx)**: Margins, border styles, widths, and repeating multi-page headers.
- 🔠 **[Cell Formatting & Alignment Guide](./docs/cell-formatting-and-alignment.mdx)**: Markdown alignment hierarchy, typography, cell shading, and block content in cells.

---

## License

This library is licensed under the MIT open-source license.

<hr />

<p align="center">with 💖 by <a href="https://mayankchaudhari.com" target="_blank">Mayank Kumar Chaudhari</a></p>

---
_Source: https://npm.io/package/@md2docx/table · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
