CSV to Markdown Table: Quotes, Delimiters and Alignment
Last updated: · 7 min read
When a README, a pull request description or a wiki page needs a table, the data usually sits in a spreadsheet or a CSV export. Typing the pipes and dashes by hand is tedious and easy to get wrong. CSV is also less simple than "split on commas": a quoted field may contain commas and line breaks, the quote itself is escaped by doubling it, and files exported in countries where the comma is the decimal separator, such as Germany, France, Spain or Turkey, are usually separated by semicolons. The CSV to Markdown Table Converter applies these rules, works out the delimiter on its own and produces a GitHub-flavoured table with padded columns. This guide covers the parsing rules, the ambiguity around delimiters and the limits of Markdown tables. The outputs in the example are the tool's real results.
Formula
Rules: 1. The delimiter is either the one you choose or detected automatically: of comma, semicolon and tab, the candidate that splits the first 10 non-empty records into the same number of fields (more than one) is selected. 2. Fields are read according to RFC 4180: a field in double quotes may contain the delimiter and line breaks; "" inside a quoted field stands for a single ". 3. Empty lines are skipped; the first record becomes the header row. 4. Leading and trailing spaces in a cell are removed; a line break inside a cell is written as <br>. 5. Characters that have a meaning in Markdown are escaped: | becomes \|, and a backslash is placed before \ ` * [ ] ~ and before an _ at the edge of a word. 6. Rows shorter than the widest record are completed with empty cells. 7. The delimiter row is written according to the alignment: left :---, center :---:, right ---:, none ---. 8. Columns are padded with spaces to equal width so that the source is easy to read (up to 60 characters per cell). Input 1 (delimiter: auto-detect, alignment: left): Name,Role,Score Ada,Engineer,92 "Lin, Wei",Designer,88 Omar,"Team ""Lead""",75 Output 1: | Name | Role | Score | | :------- | :---------- | :---- | | Ada | Engineer | 92 | | Lin, Wei | Designer | 88 | | Omar | Team "Lead" | 75 | Input 2 (delimiter: auto-detect, alignment: right): Item;Price;Note Coffee;3,50;hot|iced Tea;2,75;*new* Output 2: | Item | Price | Note | | -----: | ----: | --------: | | Coffee | 3,50 | hot\|iced | | Tea | 2,75 | \*new\* |
The reading side is based on RFC 4180. That document is an Informational RFC, not an Internet standard, and it defines the comma as the only separator; semicolon- and tab-separated files are an established convention of applications. The writing side is the table extension of GitHub Flavored Markdown: a header row, a delimiter row made of hyphens and optional colons, and the data rows. According to the specification, a pipe inside a cell is escaped as \|. The padding spaces in the columns only make the source easier to read; they do not change the rendered table.
What the inputs mean
- CSV / TSV
- The data to convert: the content of a CSV file or cells copied from a program such as Excel or Google Sheets. The first line is treated as the header. Up to 1,000,000 characters and 500,000 cells are processed.
- Delimiter
- "Auto-detect" picks whichever of comma, semicolon and tab gives consistent rows. If detection gets it wrong, choose the delimiter by hand.
- Alignment
- Applied to all columns: Left, Center, Right or None. With "None" the delimiter row consists of hyphens only and the rendering environment decides the alignment.
Worked example: Converting a comma-separated and a semicolon-separated file
- In the first input, the comma splits each of the four lines into three fields, so the comma is selected as the delimiter. The first line becomes the header: | Name | Role | Score |.
- Because the alignment is "Left", every cell of the delimiter row starts with a colon: | :------- | :---------- | :---- |.
- The field "Lin, Wei" is quoted; the comma inside it is data rather than a separator, and it is written as a single cell: Lin, Wei.
- The doubled quotes in "Team ""Lead""" are each reduced to one quote: Team "Lead".
- In the second input, the semicolon splits every line into three fields, whereas the comma would split the lines into 1, 2 and 2 fields. The consistent candidate, the semicolon, is selected, and 3,50 stays in one cell.
- Because the alignment is "Right", the delimiter row reads | -----: | ----: | --------: |. The cell hot|iced is escaped as hot\|iced and *new* as \*new\*; otherwise the pipe would split the cell and the asterisks would make the text italic.
Result: The first output is a left-aligned table with three columns and five lines; the second is a right-aligned table with three columns and four lines. In both cases the quotes, decimal commas and Markdown characters are preserved as data.
📊 CSV to Markdown Table Converter
Free, no sign-up; your data stays in your browser.
Open the calculator →How to read the result
Auto-detection looks at how consistent the column counts are. It therefore gets well-formed files right, but it cannot repair broken ones. The most common case is a comma-separated file in which numbers with a decimal comma were left unquoted: the line Coffee,3,50 has three fields, and no tool can know that 3,50 was meant as one number. The fix belongs at the source: quote the number ("3,50") or export the file with semicolons. The tool leaves number formats alone; it does not turn 3,50 into 3.50. Markdown tables have limits of their own as well. Cells cannot be merged, block content such as lists or code blocks cannot go inside a cell, and tables with hundreds of rows become unreadable; for large data sets, linking to the file is the better option. The alignment applies to all columns at once; to right-align only a numeric column, change the corresponding cell of the delimiter row to ---: by hand. This is general information.
Common mistakes
- Leaving a decimal comma unquoted in a comma-separated file. Under the header Item,Price, the line Coffee,3,50 is split into three cells: 3 and 50 land in separate columns and an empty third column is added to the header.
- Forcing the delimiter to "Comma" for a semicolon-separated file. The header becomes one cell (Item;Price;Note), while the data lines are split at the decimal comma.
- Not closing a quote. If an opening quote is never closed, the field runs on to the next quote or to the end of the file, and every line in between ends up in one cell.
- Pasting data that has no header line. The first record always becomes the header, because a GFM table cannot be written without one. Add a header line above the data.
- Deleting the \| escapes from the output. Without the backslash the pipe starts a new cell and the row shifts.
- Expecting line breaks inside cells to work everywhere. The tool writes them as <br>; where inline HTML is not allowed, the tag shows up as text.
Frequently asked questions
Can I paste cells copied from Excel or Google Sheets?
Yes. Cells copied from a spreadsheet arrive on the clipboard separated by tabs, and auto-detection selects the tab. You can also set the delimiter to "Tab (TSV)" yourself.
Why is my CSV file separated by semicolons?
In locales where the comma is the decimal separator (German, French, Spanish or Turkish, for example), spreadsheet programs generally separate fields with semicolons; otherwise every number like 3,50 would have to be quoted. RFC 4180 describes only the comma, but the tool detects semicolons and tabs as well.
How do I right-align a single column?
The tool applies the alignment to all columns. After generating the output, edit the delimiter row by hand: :--- means left, :---: center and ---: right. Disturbing the padding spaces does not affect the table.
Do the pipes have to line up?
No. According to the GFM specification, a table is defined by its header row and delimiter row, which must have the same number of cells; spaces around a cell's content do not matter. The tool pads the columns purely to make the source comfortable to read.
What happens when rows have different numbers of cells?
The tool completes missing cells with empty ones; if a row is longer than the header, an empty column is added to the header too. A result like that usually points to the wrong delimiter or to a comma that was left unquoted.
Is my data uploaded to a server?
No, the conversion runs in your browser.
The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.