How to Escape a Pipe Inside a Markdown Table Cell
To show a literal pipe in a Markdown table cell, put a backslash right before it: \|. The pipe is the character that separates cells, so an unescaped one in your content cuts the cell in two. The backslash tells the parser to treat it as plain text.
That's the whole fix. The rest covers the one case that surprises people (pipes inside backticks), what goes wrong when you forget, and a quick check before you publish.
The fix: a backslash before the pipe
Here is a small table with a pipe in a cell, written the way GitHub's own documentation shows it:
| Name | Character |
| --- | --- |
| Backtick | ` |
| Pipe | \| |The second data row renders a cell containing a single |. GitHub's guide to tables puts the instruction in one line: to include a pipe as content within your cell, use a backslash before the pipe.
The GitHub Flavored Markdown spec says the same thing in its tables section: include a pipe in a cell's content by escaping it, including inside other inline spans. That last clause matters. The escape also works inside bold text, so **\|** gives you a bold pipe.
Why does a backslash work here at all? In CommonMark, any ASCII punctuation character may be backslash-escaped, and the pipe is on that list. A backslash before a letter or a digit, on the other hand, stays a literal backslash.
Pipes inside inline code
This is where people get caught. Outside tables, backslash escapes do not work inside a code span. CommonMark says so directly: backslash escapes do not work in code blocks, code spans, autolinks, or raw HTML. So you might expect that a pipe wrapped in backticks is safe in a table cell.
It isn't. Tables are a GFM extension, and the GFM spec carves out an exception for them. Take this example from the spec:
| f\|oo |
| ------ |
| b `\|` az |
| b **\|** im |According to the spec, the second row produces a code span containing just |, and the third produces a bold |. The backslash is consumed by the table parser before the code span is read, so it does not show up in the output.
To make a cell display a | b as code, write it like this:
| Operator | Example |
| --- | --- |
| Pipe | `a \| b` |Leave the backslash out and the table parser splits the row at that pipe before it ever sees the backticks. If you document shell pipelines or regular expression alternation in a table, you will hit this often. It is the same family of problem as indented code blocks: the rules for what counts as code depend on the block you are in.
What happens when you forget
A missing escape rarely throws an error. The table just changes shape, quietly. Three things can happen, all described in the GFM spec.
Extra cells are dropped
Say your header has two columns and one data row contains a stray pipe:
| Command | Meaning |
| --- | --- |
| a | b | Alternation |That last row now has three cells: a, b, and Alternation. The spec says that if a data row has more cells than the header, the excess is ignored. Your Alternation text vanishes with no warning.
Missing cells become empty
The reverse also holds. A data row with fewer cells than the header gets empty cells added to fill the gap. So a row that lost a cell to a stray pipe elsewhere can look fine at a glance but have a blank where text should be.
The whole table falls back to a paragraph
The header row and the delimiter row (the one with the hyphens) must have the same number of cells. If a stray pipe in your header changes the count, the spec says a table will not be recognized. You get your raw pipes and hyphens printed as a paragraph. If that happens, count the cells in the header first.
Check it before you publish
Escaping is a GFM rule, so GitHub and any renderer built on the GFM spec expect it. Other Markdown apps can differ, so preview a small test table in the place you plan to publish before you convert a whole document.
Two more limits are worth knowing. A table cell takes inline content only, and block-level elements cannot be inserted in a table, so no lists or code fences inside a cell. And the table ends at the first empty line, so keep the rows together.
If your data has so many pipes and special characters that the escapes are getting in the way, a table may not be the right container. Tab-separated text pastes cleanly and needs no escaping for pipes at all.
Conclusion
Write \| for a literal pipe in a table cell, and write it inside backticks too. When a table looks wrong, count the cells per row against the header: that is nearly always where an unescaped pipe shows up. For another small syntax detail that changes how a Markdown list renders, see how bullet markers affect Markdown lists.
Frequently Asked Questions
How do I put a pipe character in a Markdown table cell?
Put a backslash right before it, like \|. In GFM the escaped pipe renders as a plain | and does not end the cell.
Do I need to escape a pipe inside backticks in a table?
Yes. In a GFM table, \| is required even inside a code span, and it renders as code containing a single pipe.
What happens if I forget to escape the pipe?
The pipe starts a new cell. Extra cells beyond the header count are ignored, so text after the pipe silently disappears. If the header and delimiter rows no longer match, the whole table falls back to a paragraph.
Does the backslash escape work in every Markdown app?
It is the GFM rule, used by GitHub and renderers built on the GFM spec. Other apps can differ, so preview a test table in the app you publish to.