Tables in Markdown

Interactive Markdown tutorial on tables: build rows and columns with pipes and dashes, and control column alignment. Edit a live example and see the result instantly.

Markdown tables are drawn with two characters: the pipe | separates columns, and a row of dashes - separates the header from the body. Once you see the shape, they’re quick to write.

The basic shape

Three parts: a header row, a separator row of dashes, then one body row per line:

| Test   | When to use         |
|--------|---------------------|
| t-test | two group means     |
| ANOVA  | three or more means |

The columns don’t need to line up perfectly in your source — the extra spaces are just for your own readability. What matters is that every row has the same number of | separators.

Alignment

Add a colon : in the separator row to align a column. :--- is left, ---: is right, and :---: is centered:

Here the first column is left-aligned, the middle is centered, and the numbers on the right are right-aligned — which is the convention for numeric columns. Try adding a row, or moving the colons around.

For big tables generated from data, you usually won’t write them by hand — in R you’d use knitr::kable() or gt/gtsummary to build them automatically. See our post on publication-ready baseline tables.


Next: Markdown flavours → — why the same Markdown behaves differently in different tools.