MDUtil

Tables in Markdown

Separate columns with | and put a row of dashes under the header. This guide covers alignment, formatting inside cells, escaping pipes, line breaks, and what to do when Markdown tables are not enough.

Quick answer

How do you make a table in Markdown?

Write the header cells between pipes, then a row of dashes, then one line per row: | Name | Role |, | --- | --- |, | Ana | Design |. Colons in the dash row set the alignment. Tables come from GitHub Flavored Markdown and work in most editors and on GitHub.

Markdown
| Name | Role | Since |
| --- | --- | --- |
| Ana | Design | 2021 |
| Ben | Engineering | 2019 |

Result

NameRoleSince
AnaDesign2021
BenEngineering2019

Table syntax and examples

The columns in the source do not need to line up; the renderer builds the grid from the pipes.

Column alignment

A colon on the left of the dashes aligns left, colons on both sides center, and a colon on the right aligns right, which suits numbers.

Markdown
| Item | Qty | Price |
| :--- | :---: | ---: |
| Apples | 3 | 1.20 |
| Pears | 12 | 4.80 |

Result

ItemQtyPrice
Apples31.20
Pears124.80

Formatting inside cells

Cells can hold bold text, inline code, links, images and strikethrough, but no lists or code blocks.

Markdown
| Option | Default | Notes |
| --- | --- | --- |
| `--force` | **off** | Skips [checks](https://example.com/checks) |
| `--quiet` | on | ~~Verbose~~ Silent output |

Result

OptionDefaultNotes
--forceoffSkips checks
--quietonVerbose Silent output

Pipes and line breaks in cells

Escape a pipe in a cell as \|, even inside code. Use <br> to start a new line in a cell.

Markdown
| Operator | Meaning |
| --- | --- |
| `a \| b` | a or b |
| `&&` | Both must be true,<br>checked left to right |

Result

OperatorMeaning
a | ba or b
&&Both must be true,
checked left to right

Minimal syntax

The outer pipes and the spacing are optional. Lining up the columns only makes the source easier to read.

Markdown
Name | Role
--- | ---
Ana | Design
Ben | Engineering

Result

NameRole
AnaDesign
BenEngineering

Empty header

A table always has a header row. Leave its cells empty when the table does not need one.

Markdown
| | |
| --- | --- |
| Monday | Gym |
| Tuesday | Piano |

Result

MondayGym
TuesdayPiano

Merged cells with HTML

Markdown tables cannot merge cells. Where HTML is allowed, write an HTML table with colspan or rowspan.

Markdown
<table>
  <tr><th colspan="2">Opening hours</th></tr>
  <tr><td>Mon–Fri</td><td>9:00–18:00</td></tr>
  <tr><td>Sat</td><td>10:00–14:00</td></tr>
</table>

Result

Opening hours
Mon–Fri9:00–18:00
Sat10:00–14:00

Tables in popular apps

Every app that follows GitHub Flavored Markdown shows tables. Chat apps do not.

AppSupportNotes
GitHub / GitLabSupportedTables with alignment; wide tables scroll sideways.
ObsidianSupportedTables show in reading view and live preview.
VS Code / TyporaSupportedTables show in the preview; Typora edits them as a grid.
RedditSupportedTables work in posts and comments.
Discord / SlackNot supportedTables appear as plain text; a code block keeps the columns lined up.

Questions and answers

How do I align text in a table column?

Add colons to the dash row under the header: :--- aligns left, :---: centers and ---: aligns right.

Can I merge cells in a Markdown table?

No. Write an HTML table with colspan or rowspan where HTML is allowed.

How do I add a line break inside a cell?

Write <br> where the line should break. A real line break ends the row.

How do I put a pipe character in a cell?

Escape it with a backslash: \|. This is needed inside code spans as well.

Why is my table not rendering?

Check that a dash row follows the header and has as many cells as the header, that every row is on one line, and that the table is not indented four spaces, which turns it into code. Inside a list item, indent the table to the item's text.

Can I put a list or code block in a cell?

Not with Markdown: cells hold one line of text. Use <br> between items, or an HTML table where HTML is allowed.

How do I make a table quickly?

Edit the cells in a grid with the Markdown Table Generator, or convert a spreadsheet with CSV to Markdown Table.

Do tables work in Discord or Slack?

No. Put the table in a code block to keep the columns lined up.