Markdown Table Generator
Paste data from a spreadsheet to get a pipe table with a separator row, left/center/right alignment and width padding (CJK counts as two columns); pipes are escaped and line breaks become <br>. The parser mode reverses it.
Turning tabular data into Markdown is a frequent chore: data copied from a spreadsheet or CSV has to be given pipes and a separator row by hand, slowly and with frequent misalignment. This tool pads each column to its display width (a CJK character counting as two) and emits a table that pastes straight into a README or a docs page; it also parses an existing table back into row data for reimport into a spreadsheet.
Two things to keep in mind. A Markdown table is recognised by its second line — the separator row of pipes and dashes — so that row cannot be omitted, and alignment is declared there too (left by default; colons at one or both ends give left, right or centre). And a pipe inside a cell must be escaped and a line break written as a br tag, or the table breaks and renders misaligned.
Did this tool solve your problem?
Submitting sends the tool name, your input and the current result to the server. Please do not include ID numbers, phone numbers or other private data.
AI assistant It answers using your current input and result
Asking again sends your current input and result to the server once more. Please do not include private data.
How to use
- Paste spreadsheet or CSV data (tabs and commas both work).
- Read the generated table with its separator row and alignment markers.
- Switch to parse mode to turn an existing table back into rows.
- Remember that pipes in cells are escaped and line breaks become br tags.
How it works
Why the separator row is mandatory
A Markdown table is recognized by the separator row on the second line (`| --- | :--: |`), which also declares each column's alignment: `---` default left, `:--` left, `--:` right, `:-:` center. Without that row, most renderers treat the whole thing as a paragraph of pipes.
What column padding does
Column padding is purely cosmetic: spaces are added to the right of each cell up to the column's widest entry (Chinese and fullwidth characters count as 2 columns), aligning the source in monospace fonts for easier reading and maintenance. It doesn't affect rendering, so if diff noise bothers you, turn padding off for compact tables.
Escaping and round-tripping boundaries
Pipes inside cells must be written `\|`, or they'd split one cell into two; newlines inside cells are unsupported in Markdown tables, so they become <br> tags for the renderer. Parse mode reverses both, so "generate → parse" returns the original data — but if your original text already contained <br>, parsing turns it into a real newline: one lossy point.
Code example
JavaScript Turning an array of objects into a Markdown table
const toMdTable = (rows) => {
if (!rows.length) return '';
const head = Object.keys(rows[0]);
const esc = (v) => String(v ?? '').replace(/\|/g, '\\|').replace(/\n/g, '<br>');
const line = (cells) => '| ' + cells.join(' | ') + ' |';
return [
line(head),
line(head.map(() => '---')),
...rows.map((r) => line(head.map((h) => esc(r[h])))),
].join('\n');
};
console.log(toMdTable([
{ name: 'Basic', price: 0, note: 'Personal use' },
{ name: 'Pro', price: 99, note: 'Includes batch export' },
]));
Shell Building a table from CSV (simple case)
# First row as the header, commas to pipes (fine when fields contain no commas)
awk -F, 'NR==1{printf "| %s |\n|", $0; n=NF; for(i=0;i<n;i++) printf " --- |"; printf "\n"; next}
{gsub(/,/," | "); printf "| %s |\n", $0}' data.csv
# If fields contain commas, use a real CSV parser instead (see the JavaScript example above)
# Note: paste the result into your editor and preview once to confirm the columns line up
FAQ
Will the generated table render on GitHub and Typora?
Yes. The output is the most universal pipe-table syntax — only pipes, hyphens and colons — supported by GitHub, GitLab, Typora, Obsidian and VS Code previews, with no extension dependencies.
Can the second-line separator be omitted?
No. The separator row is the only thing that makes Markdown see a table; without it the block renders as plain text. The tool always outputs it; you can reduce spaces with the "no padding" option, but the separator stays.
What if a cell contains a pipe?
The tool escapes it to `\|` automatically so it isn't mistaken for a column separator. Parsing existing tables restores `\|` back to a pipe, so "generate → parse" round-trips the original content.
Can cells contain line breaks?
Markdown table syntax doesn't support them. This tool converts newlines into <br> tags, which most renderers display as a break. Parse mode restores <br> to newlines — meaning a literal <br> already in your data becomes an actual line break: the one lossy case.
Where's the easiest place to copy data from?
Select a range in Excel, Numbers, Feishu Sheets or a database client and paste — you get one record per line with Tab-separated fields, and the tool splits on Tab. For pure CSV text, switch the separator to comma. Keep "first row is header" enabled when the first line is a header.
Does column padding bloat the file?
Each cell pads to its column's widest entry plus one space — typically a dozen to a few dozen extra characters per row. If repo size or diff noise matters, turn off "pad columns" for compact output; rendering is identical.
How is the width of Chinese cells computed?
By display width: Han characters and fullwidth punctuation count as 2 columns, letters and digits as 1 — that's what makes alignment genuinely line up in monospace fonts. With mixed content you'll see more spaces after English fields; that's correct.
Can it parse a table someone else wrote?
Yes. Switch to parse mode and paste the table to recover row-by-row data: the tool reads alignment markers, handles `\|` escapes, and pads short rows with empty strings when column counts differ. Without a valid separator row it clearly reports "not a table" instead of guessing.