CSV to Markdown: keep quotes, line breaks and pipes

Turn copied table data into Markdown while checking cell contents, alignment, backslashes and whitespace.

Content reviewed ·

The problem and context

Copying from a spreadsheet often separates columns with tabs. Exported CSV can place commas, double quotes and line breaks inside one quoted field. RFC 4180 provides an informational description of common CSV records, while Markdown tables depend on implementation extensions. Reading complete records before generating a table preserves those field boundaries.

Method and calculation

Choose CSV, TSV or automatic detection. Automatic mode counts only delimiters outside quotes; select an explicit format if both occur. Literal text is the default, retaining Markdown punctuation and HTML-like text. Enable Markdown syntax when formatting such as emphasis is intentional. The first record is the header; short records receive empty cells and long records expand the column count.

Worked example

Put a\|b in a field, with both the backslash and pipe belonging to the data. Adding just another slash before the pipe can make Markdown split a new column. Literal mode handles the pair together so the rendered cell retains both characters. Two quoted lines use <br> within one cell. **Ada** retains its stars in literal mode and its emphasis syntax in Markdown mode.

Checklist

Check data-row, column and header-inclusive cell counts before copying or downloading table.md. Source is displayed as text. Limits are 1000000 UTF-16 input units, 10000 data rows plus a header, 1000 columns, 200000 padded cells and 2000000 output units. Empty and duplicate headers remain; NUL and incomplete UTF-16 characters produce errors.

Markdown Table Generator

Table data

Up to 1000000 UTF-16 input units, 10000 data rows plus a header, 1000 columns and 200000 padded cells; output up to 2000000 units.

Generation options

Literal text is the default, retaining backslashes, pipes, edge spaces and repeated spaces. Enable the option to keep Markdown formatting syntax. Cell line breaks become line-break tags.

Markdown table

| Name | Note                      |
| :--- | :------------------------ |
| Ada  | a\\\|b                    |
| Lin  | first line<br>second line |
Data rows
2
Columns
2
Cells including header
6
Output UTF-8 bytes
147

Use these tools with this article

  • JSON Tools

    Online JSON tool supporting formatting, compression, validation and beautification. Essential tool for developers, runs locally.

  • HTML Entities

    Convert between HTML entities and characters: named, decimal and hex forms.

  • MD Table

    Convert CSV or tab-separated data to a Markdown table, retain quoted line breaks, choose left, center or right alignment, then copy or download.

  • CSV ⇄ JSON

    Convert header-based CSV and JSON object arrays with comma, semicolon or tab delimiters.

Sources