How to use the markdown table prettifier
- Paste your Markdown. It can hold one table or a whole document with tables in it.
- Choose Aligned columns to pad the cells so the pipes line up, or Compact to only trim the spaces.
- Check the count of tables, rows and dropped cells.
- Copy the tidy Markdown or download it as a .md file.
Formula
Column width = the widest cell in the column, and at least 3
Left or no alignment: cell + spaces. Right alignment: spaces + cell. Center: spaces split on both sides
Delimiter row: :--- left, ---: right, :---: center, --- none
Wide characters such as Chinese count as two columns, and combining marks count as none.
A ragged fruit table
The pasted text has the lines |Item|Qty|Price|, |:--|:-:|--:|, |Apples|3|1.20|, |Pears, green|12|0.5| and |Plums \| ripe|10|0.80|. The result is a table whose columns are 13, 3 and 5 characters wide: the Item column is padded on the right, the Qty column is centered and the Price column is padded on the left, so the numbers line up on the right.
The compact layout gives | Item | Qty | Price | followed by | :-- | :-: | --: |, with each cell trimmed to one space either side. The escaped pipe in Plums \| ripe is kept as it was, so the cell still reads as one cell. The note below the table is copied unchanged.
What is changed and what is not
Only table lines are rewritten. A table is a header line with pipes, a line of dashes with the same number of cells and the rows after it, up to a blank line or a line with no pipe. Everything else in your document, including headings, lists and paragraphs, is copied as it was. Tables inside code fences, block quotes and indented code are left alone, because there the pipes are text and not a table.
Short rows are padded with empty cells so every row has the same number of cells as the header. Cells beyond the last column are dropped and counted, so you can see if anything was lost.
Alignment markers and widths
A colon at the left of the dashes means left alignment, a colon at the right means right alignment and a colon at both ends means center. The tool pads the cells to match: a number column marked right lines up its digits, and a centered column puts the extra space on the right when the padding is uneven. Most Markdown renderers ignore the padding, so the tidy version looks the same when rendered and is easier to edit as text.
To build a table from scratch, use the Markdown Table Generator, and to turn one into data use the Markdown Table to CSV Converter. The ASCII Box Table Formatter draws tables with box characters, and the Markdown Editor and Previewer shows the result as it will be rendered. The Markdown to Plain Text Stripper removes the symbols afterward.
Assumptions and limits
- Pipe tables in the common style are read. Tables written with other extensions are not.
- Widths count characters on screen. Fonts that are not monospace will not line up whatever the tool does.
- A line that starts with a quote arrow or four spaces is not treated as the start of a table.
- Line endings follow the text you paste. If it has Windows line endings, the result does too.
Frequently asked questions
Will this change how my table looks when rendered?
No. Renderers ignore the extra spaces. Only the source text changes.
Why was a table not changed?
It may be inside a code fence, a quote or indented code, or its dash line may have a different number of cells than the header line.
Does it keep the alignment of my columns?
Yes. The colons in the dash line are read and written back, and they decide how the cells are padded.
What happens to a pipe inside a cell?
A pipe written as \| stays escaped, so it does not split the cell. The width counts it as one character.