<!-- Markdown Table Syntax: Alignment and Escaping -->
<!-- Canonical: https://dataswitchpro.com/guides/markdown-table-syntax/ -->
> How to make a table in Markdown: header and separator rows, column alignment, escaping pipes, line breaks in cells, and spreadsheet to Markdown.

[Home](https://dataswitchpro.com/) › [Guides](https://dataswitchpro.com/guides/)

# How to Make a Table in Markdown: Syntax, Alignment and Escaping

By the DataSwitch Pro team · November 20, 2026 · 4 min read

## Quick answer

A Markdown table is written with pipes (`|`) between cells: a header row, then a separator row of dashes such as `| --- | --- |`, then one line per row. Add colons to the separator to align a column (`:---` left, `:---:` center, `---:` right), escape a pipe inside a cell as `\|`, and use `<br>` for a line break inside a cell. Tables are part of GitHub Flavored Markdown, supported by GitHub, GitLab and most documentation tools, but not by the original Markdown.

Tables are the quickest way to compare options in a README, document an API's parameters or summarise results in a pull request. The syntax is small, but a few details trip people up.

## The basic syntax

### Markdown

```
| Format | Comments | Typical use   |
| ------ | -------- | ------------- |
| JSON   | No       | APIs          |
| YAML   | Yes      | Config files  |
| CSV    | No       | Spreadsheets  |
```

- The **first row** is the header.
- The **second row** separates header from body. It is required; without it, the lines render as plain text.
- Each following line is one row. Outer pipes are optional but make tables easier to read.
- The columns do not need to line up in the source — aligning them is only for human readers.

## Aligning columns

### Markdown

```
| Item      | Qty | Price |
| :-------- | :-: | ----: |
| Mug       |  2  | 12.50 |
| Glass jar |  1  |  8.90 |
```

A colon on the left aligns left, colons on both sides centre, and a colon on the right aligns right — use right alignment for numbers so decimals line up.

## Special content in cells

- **Pipes**: write `\|`, otherwise the pipe starts a new cell. Inside inline code, some renderers still need the escape.
- **Line breaks**: a cell must stay on one line. Use `<br>` where a break is needed (GitHub renders it).
- **Formatting**: bold, italics, links and `` `inline code` `` work inside cells.
- **Empty cells**: leave nothing between two pipes, `| |`.
- **Lists and code blocks** are not possible inside a Markdown table cell. If you need them, use an HTML table instead.

## Things Markdown tables cannot do

- Merged cells (colspan or rowspan).
- Tables without a header row.
- Column widths, colours or borders — styling comes from the site's CSS.
- Captions; add a sentence above the table instead.

When you need any of these, write HTML directly (GitHub accepts a subset of HTML in Markdown), or generate it with [CSV to HTML Table](https://dataswitchpro.com/csv-to-html/).

## From a spreadsheet to a Markdown table

Typing pipes for more than a few rows is tedious and error-prone. Faster:

1. In Excel or Google Sheets, select the range and export or copy it as CSV (or tab-separated text).
2. Paste it into the [CSV to Markdown converter](https://dataswitchpro.com/csv-to-markdown/). Pipes in values are escaped and line breaks become `<br>` automatically.
3. Copy the table into your README, issue or wiki page.

If the source is a table on a web page, extract it first with [HTML Table to CSV](https://dataswitchpro.com/html-table-to-csv/).

## Where tables work

Tables come from GitHub Flavored Markdown (GFM) and are supported by GitHub, GitLab, Bitbucket, Notion, Obsidian, Docusaurus, MkDocs, Jekyll and most modern documentation tools. Some chat apps, including Slack, do not render Markdown tables. When a table shows as raw pipes, check that the separator row is present, that there is a blank line before the table, and that the tool supports GFM tables at all.

## Keeping large tables maintainable

Markdown tables are best for small, mostly static data. If a table has dozens of rows or changes often, keep the data in a CSV file in the repository and regenerate the Markdown when it changes. That way the CSV stays the source of truth and the table never drifts out of date.

**Try it on your own file.** Free, private, and processed in your browser.

[CSV to Markdown](https://dataswitchpro.com/csv-to-markdown/)[CSV to HTML Table](https://dataswitchpro.com/csv-to-html/)[Excel to CSV](https://dataswitchpro.com/excel-to-csv/)[HTML Table to CSV](https://dataswitchpro.com/html-table-to-csv/)

## Frequently asked questions

### Why is my Markdown table showing as plain text?

The separator row (dashes) is missing or malformed, there is no blank line before the table, or the renderer does not support GFM tables.

### How many dashes does the separator need?

GitHub accepts a single dash per column, but three or more is the common convention and works in more renderers.

### Can I merge cells in Markdown?

No. Use an HTML table if you need colspan or rowspan.

### Can I convert a Markdown table back to CSV or Excel?

Copy the rendered table from the page into a spreadsheet, or remove the separator row and treat the pipes as delimiters.

## More guides

- [How to Display a CSV File as an HTML Table on Your Website](https://dataswitchpro.com/guides/csv-to-html-table-website/)
- [Why Your CSV Opens in One Column in Excel (and How to Fix It)](https://dataswitchpro.com/guides/csv-opens-in-one-column-excel/)
- [Fix Garbled Characters (Ã©, â€™, Ã¨) in CSV Files Opened in Excel](https://dataswitchpro.com/guides/fix-garbled-characters-csv-excel/)
- [How to Copy a Table from a Website into Excel or CSV](https://dataswitchpro.com/guides/copy-table-from-website-to-excel/)
