Nested tables in Markdown

Can you put a Markdown table inside a table? What standard syntax allows, the HTML and Pandoc workarounds, and when a flattened table or plain text works better.

People usually look for a table within a table when their data has a parent-child shape: plans with feature lists, categories with sub-items, or records that each carry a small grid of details. Markdown handles flat grids well, but it has no native way to nest one table inside another. This review explains what the common syntaxes allow, what the workarounds actually change, and when a nested layout is worth the cost to readability and portability.

Short answer: is a nested table suitable for your use?

For most documents, no. The main benefit of nesting is visual grouping: related values sit inside the row they belong to. The decisive tradeoff is that every route to nesting depends on a specific renderer, either through raw HTML or through a Markdown flavor with extended table syntax. Output that looks right in one viewer can collapse into unreadable source text, a single long line, or escaped tags in another.

A nested table is reasonable when you control the renderer, the audience reads the rendered page rather than the source, and the inner data is genuinely tabular. Prefer a flattened table, separate tables under headings, or plain text when the content will be copied into other tools, read with assistive technology, edited by many contributors, or published to destinations you have not tested.

What the transformation actually changes

Turning nested data into Markdown is a formatting transformation, not a character transformation. The words and numbers stay the same; what changes is the markup around them and how a renderer interprets that markup. It helps to keep two layers separate: the stored source text, which is what gets saved, diffed, searched and copied from an editor, and the rendered presentation, which is what a viewer draws on screen. A nested table can exist convincingly in the second layer while the first layer is a mix of pipes, tags and blank lines that only a matching renderer understands.

Terms like reverse, mirror or font, which come up in other text-styling tools, do not apply here. Nothing about nesting reorders characters, flips glyphs or substitutes look-alike Unicode symbols. The only risk to the text itself is escaping: characters that the table syntax treats as structure, chiefly the pipe, must be escaped or the cell boundaries shift.

Standard Markdown and GitHub Flavored Markdown

CommonMark, the baseline specification, does not define tables at all. GitHub Flavored Markdown (GFM) adds pipe tables as an extension, and its specification limits each cell to inline content. Block elements such as paragraphs, lists, code blocks or another table cannot appear inside a GFM cell, and a cell cannot span multiple source lines. A literal pipe inside a cell has to be written as a backslash followed by the pipe, and in GFM that applies even inside inline code spans.

In practice, this means a pipe table cannot contain another pipe table. If you try, the inner rows are read as rows of the outer table or as stray text, not as a nested grid.

Workaround 1: an HTML outer table with a Markdown inner table

Many renderers accept raw HTML, so the outer table can be written in HTML. Under CommonMark's HTML-block rules, an HTML block that starts with a tag such as td ends at the next blank line, and the content after that blank line is parsed as Markdown again. Surrounding the inner Markdown table with blank lines therefore lets it render inside the HTML cell, on renderers that follow those rules and do not strip table tags.

<table>
<tr>
<th>Plan</th>
<th>Details</th>
</tr>
<tr>
<td>Plan A</td>
<td>

| Feature | Included |
| ------- | -------- |
| Export  | Yes      |
| Sharing | No       |

</td>
</tr>
</table>

The blank lines after the opening td and before the closing td are what make this work. Remove them and the inner pipe table is treated as part of the raw HTML block, so it appears as literal pipes and dashes. The example data is illustrative only.

Workaround 2: HTML all the way down

Writing both tables in HTML avoids relying on blank-line parsing, and nested table elements are valid HTML. The cost is that the source stops being readable Markdown, and some platforms sanitize or remove HTML entirely, in which case the reader sees either raw tags or stripped text with no structure.

Workaround 3: extended syntaxes

Pandoc's grid tables allow block-level content inside cells, which is the closest Markdown-family syntax to true nesting. Whether a table placed inside a grid table cell survives depends on the Pandoc version and the output format, so it should be tested for the specific conversion you need. Outside Markdown, AsciiDoc documents a dedicated nested-table syntax, which may suit projects that are free to change markup languages.

Alternatives that avoid nesting

  • Flatten the data: repeat the parent value on each child row, so one table carries both levels.
  • Split into several tables, each under a heading named for the parent item.
  • Use a short list or line breaks inside a cell for small sets of values; GFM permits inline HTML such as a line-break tag in cells where the renderer allows it.
  • Move deep detail into a separate section and refer to it from the summary table.

Flattening the earlier example produces a single GFM table that works anywhere pipe tables are supported:

| Plan   | Feature | Included |
| ------ | ------- | -------- |
| Plan A | Export  | Yes      |
| Plan A | Sharing | No       |

Will the result stay readable after copying or sharing?

Readability depends on which layer travels. Copying the source moves the markup, and the destination must support the same flavor and HTML policy for the nested layout to reappear; otherwise readers see tags, pipes and blank lines. Copying from a rendered page hands the destination whatever the browser or viewer puts on the clipboard, and how an editor, email client or spreadsheet interprets a nested table varies by application and version. No tests of specific destinations were supplied for this review, so any target that matters should be checked directly.

Accessibility is the stronger argument against nesting. Screen readers announce table structure and associate cells with their headers, and a table inside a table adds a second set of rows, columns and headers that the listener must track. Accessibility guidance generally favors simple data tables with clear header cells over nested or layout-driven tables. A flattened table or separate tables with headings usually conveys the same relationships with less navigation effort. This is a general principle; behavior with any particular screen reader was not tested here.

Editing and search are also affected. Mixed HTML and Markdown is harder to diff and review, easy to break by deleting a single blank line, and unfamiliar to contributors who expect plain pipe tables. The underlying words remain searchable as text in the source, but the relationship between an inner value and its outer row is visible only after rendering.

Provide a plain-text or flattened equivalent when the content is likely to be pasted into chat, email, tickets or spreadsheets, when it must work without HTML support, or when accessibility requirements apply.

Evidence gaps

This review rests on documented syntax rules for CommonMark, GFM and Pandoc. It does not include verified rendering tests on named platforms, editors or assistive technologies, and no measurements of compatibility were available. Treat the workarounds above as approaches to confirm in your own target environment rather than as guaranteed results.