Markdown Table Syntax: Complete Guide
Tables are the most commonly searched Markdown feature. This guide covers everything from basic syntax to advanced techniques, so you never have to look it up again.
Why Tables Are the Top Markdown Pain Point
If you have ever written Markdown, you have almost certainly searched for "Markdown table syntax" at least once. Tables are unique among Markdown features because their syntax is both visually intuitive and surprisingly tricky to get right. Unlike headings or bold text, where the syntax is a simple prefix or wrapper, tables require you to align pipes and hyphens across multiple lines, manage column widths, and handle edge cases like empty cells or content that contains pipe characters.
This guide is designed to be the last Markdown table reference you will need. We cover the basic syntax, alignment options, complex content in cells, multiline techniques, and common pitfalls. Every example is copy-paste ready. If you prefer a visual approach, our Markdown tool includes a Table Generator tab that lets you build tables by clicking, then copy the generated syntax.
Basic Table Syntax
A Markdown table consists of three parts: the header row, the separator row, and one or more data rows. Pipes (|) separate columns, and hyphens (-) in the separator row define column boundaries.
| Name | Role | Location |
|----------|------------|-----------|
| Alice | Engineer | Berlin |
| Bob | Designer | London |
| Charlie | PM | New York |The header row defines the column names and is always the first row. The separator row immediately follows and must contain at least three hyphens per column. Data rows follow the separator. The number of columns is determined by the header row, and every subsequent row must have the same number of columns (or fewer, in which case trailing cells are empty).
The outer pipes at the beginning and end of each row are technically optional in most parsers. However, including them is strongly recommended because they make the table structure immediately visible in the raw source and prevent ambiguity in edge cases.
Name | Role | Location
---------|------------|----------
Alice | Engineer | Berlin
Bob | Designer | London
(Works in most parsers, but less readable in source)Column Alignment
Column alignment is controlled by placing colons in the separator row. This is one of the most useful and frequently forgotten features of Markdown tables. There are three alignment options:
| Left-aligned | Center-aligned | Right-aligned |
|:-------------|:--------------:|--------------:|
| Text | Text | Text |
| More text | More text | More text |- Left-aligned (default): Colon on the left side of the hyphens, or no colon at all.
:---or---- - Center-aligned: Colons on both sides.
:---: - Right-aligned: Colon on the right side.
---:
Right alignment is particularly useful for numeric columns (prices, counts, percentages) where decimal points and digit alignment improve readability. Center alignment works well for short categorical values and status indicators.
| Package | Version | Size | Downloads |
|:------------|:-------:|:------:|----------:|
| react | 19.2 | 2.5 kB | 45.2M |
| next | 16.1 | 8.1 kB | 6.8M |
| typescript | 5.9 | 5.4 MB | 12.1M |Formatting Content Inside Cells
Table cells support most inline Markdown formatting. You can use bold, italic, code, links, and even images inside cells. However, block-level elements like headings, lists, blockquotes, and code blocks are not supported inside table cells.
| Feature | Syntax | Example |
|---------------|--------------------|--------------------|
| **Bold** | `**text**` | **bold text** |
| *Italic* | `*text*` | *italic text* |
| `Code` | `\`code\`` | `inline code` |
| ~~Strike~~ | `~~text~~` | ~~struck text~~ |
| [Link](#) | `[text](url)` | [Example](#) |
| Image | `` |  |When combining formatting inside cells, keep the content concise. Wide cells push the overall table width beyond comfortable reading widths, especially on mobile devices. If you need to include extensive content in a table, consider whether a different format (such as a definition list or a series of cards) might be more appropriate.
Handling Pipe Characters in Cells
Since the pipe character (|) is the column delimiter, including a literal pipe inside a cell requires escaping. Use the backslash: \|.
| Expression | Result |
|----------------|--------|
| true \| false | true |
| a \|\| b | a or b |
| cmd1 \| cmd2 | pipe |This is one of the most common table syntax errors. If your table renders with the wrong number of columns, check for unescaped pipes inside cell content. This is especially common when documenting shell commands (which use | for piping), logical operators (||), and regular expressions.
Empty Cells and Minimal Syntax
Empty cells are created by placing nothing between two pipes. The separator row requires at least three hyphens per column, but the hyphens do not need to visually align with the header or data (though alignment is recommended for readability).
| A | B | C |
|---|---|---|
| 1 | | 3 |
| | 2 | |
| 1 | 2 | 3 |The minimal valid table is surprisingly compact. Each separator column needs only three characters: a hyphen or colons. However, there is no benefit to minimizing table width in your source. Wider, padded tables are significantly easier to read and edit in raw form.
Multiline Content in Cells
Standard Markdown tables do not support true multiline content within a cell. Each table row must be a single line. However, there are workarounds for situations where you need line breaks within a cell.
Using HTML Break Tags
| Feature | Description |
|------------|------------------------------------------------|
| Auth | JWT-based authentication<br>OAuth2 support |
| Database | PostgreSQL<br>Redis for caching<br>S3 for files |The <br> tag is the most reliable way to create line breaks within table cells. It is supported by GitHub, GitLab, and most Markdown renderers that allow inline HTML. While it is technically mixing HTML into Markdown, it is widely accepted as the standard approach for this specific use case.
Using HTML Lists Inside Cells
| Service | Endpoints |
|----------|--------------------------------------------------|
| Users | <ul><li>GET /users</li><li>POST /users</li></ul> |
| Orders | <ul><li>GET /orders</li><li>PUT /orders/:id</li></ul> |HTML lists inside cells work on GitHub but are not supported by all Markdown renderers. Test in your target platform before relying on this approach. A safer alternative is to use comma-separated values or the <br> technique.
Markdown Tables vs HTML Tables
Markdown tables are convenient for simple data, but they have limitations. Understanding when to use each format helps you choose the right approach for your content.
<!-- Markdown table: simple, readable in source -->
| Method | Path | Auth |
|--------|-----------|----------|
| GET | /users | Required |
| POST | /users | Admin |
<!-- HTML table: complex layouts, merged cells, styling -->
<table>
<thead>
<tr>
<th rowspan="2">Method</th>
<th colspan="2">Endpoints</th>
</tr>
<tr>
<th>Path</th>
<th>Auth</th>
</tr>
</thead>
<tbody>
<tr>
<td>GET</td>
<td>/users</td>
<td>Required</td>
</tr>
</tbody>
</table>Use Markdown tables when the data is straightforward: uniform columns, single-line cell content, no merged cells. Use HTML tables when you need colspan, rowspan, complex formatting, or precise styling control. In README files and documentation, Markdown tables should cover 90% or more of your table needs.
Common Mistakes and Troubleshooting
When a Markdown table does not render correctly, the cause is almost always one of these issues:
- Missing separator row: The row of hyphens between the header and data is mandatory. Without it, the parser treats the content as regular text, not a table.
- Inconsistent column count: Every row must have the same number of pipe-separated columns. If one row has 4 columns and another has 3, the table may not render.
- No blank line before the table: Most parsers require a blank line before the table starts. If the table immediately follows a paragraph, it may be treated as part of that paragraph.
- Unescaped pipes: Literal pipe characters in cell content must be escaped with
\|. Unescaped pipes create extra columns. - Trailing spaces: Some parsers are sensitive to trailing whitespace. If a table behaves unexpectedly, try trimming trailing spaces from each line.
<!-- WRONG: Missing separator row -->
| Name | Value |
| Alice | 100 |
<!-- CORRECT: Include separator -->
| Name | Value |
|-------|-------|
| Alice | 100 |
<!-- WRONG: Inconsistent columns -->
| A | B | C |
|---|---|---|
| 1 | 2 |
| 3 | 4 | 5 |
<!-- CORRECT: Match column counts -->
| A | B | C |
|---|---|---|
| 1 | 2 | |
| 3 | 4 | 5 |Tools for Working with Markdown Tables
Writing Markdown tables by hand is tedious, especially for tables with many columns or long cell content. Several approaches can make the process faster:
- Visual generators: Our Markdown tool's Table Generator lets you define rows and columns visually, set alignment, enter content, and copy the generated Markdown. This is the fastest way to create well-formatted tables.
- CSV/TSV conversion: If your data is in a spreadsheet, export it as CSV and convert to Markdown table syntax. Many online tools and editor extensions handle this conversion.
- Editor extensions: VS Code extensions like "Markdown All in One" provide table formatting commands that automatically align pipes and pad cell content.
- Programmatic generation: For documentation that includes tables generated from data (API endpoint lists, configuration options), generate the Markdown tables from code rather than maintaining them by hand.
Best Practices
Based on years of writing and reviewing Markdown documentation, here are the practices that lead to the best results:
- Always align pipes vertically in your source for readability. While not required by parsers, aligned source is dramatically easier to edit and review.
- Keep cell content short. If a cell needs more than a few words, consider restructuring the information.
- Use header rows that clearly and concisely describe each column. Avoid abbreviations that might be unclear to new readers.
- Apply alignment only where it improves readability. Right-align numeric columns. Left-align text columns. Center alignment is rarely needed.
- Include a blank line before and after every table to ensure correct parsing.
- Test your tables in the target renderer. GitHub, GitLab, VS Code preview, and other tools may render edge cases differently.
Further Reading
- GFM tables specification
The GitHub Flavored Markdown specification for table syntax.
- CommonMark specification
The standard Markdown specification (note: tables are a GFM extension).
- Markdown Guide — Extended Syntax
Practical guide to Markdown table syntax with examples.