What does the Markdown Table Generator do?
The Markdown Table Generator helps developers, technical writers, and open-source contributors convert tabular data (CSV, TSV, Excel copies, JSON arrays) into clean GitHub Flavored Markdown (GFM) tables. It handles column padding, alignment markers (:---, :---:, ---:), and header separation lines.
Core Concepts
Understanding GitHub Flavored Markdown (GFM) Table Syntax:
- Header Line: Defines column titles enclosed in pipe characters (
| Column 1 | Column 2 |). - Separator Line: Specifies column alignment using colons and hyphens:
- Left Align:
| :--- | - Center Align:
| :---: | - Right Align:
| ---: |
- Left Align:
- Data Rows: Formats cell contents into matching pipe-separated rows.
How to use the tool?
- Paste Input Data: Paste your CSV, TSV (copied directly from Microsoft Excel or Google Sheets), or JSON array into the input box.
- Select Options: Choose the input format and default column alignment.
- Copy Markdown Table: Click
Copyon the generated Markdown table to use in GitHub READMEs, PRs, or documentation.
Related Developer Utilities
If you work with documentation and web formats, explore these complementary tools:
- Markdown to HTML Converter: Convert Markdown documents into formatted HTML markup.
- HTML to Markdown Converter: Extract clean Markdown text from raw HTML snippets.
REST API Integration
Blueutils provides a free REST API endpoint (POST https://blueutils.com/api/markdown/table-generator) to programmatically convert CSV or JSON tabular data into GitHub Markdown tables.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
text |
String | Input tabular text (CSV, TSV, JSON array, or Markdown). | "Name, Role\nAlice, Engineer" |
format |
String | Input format: "csv", "tsv", "json", or "markdown". Default "csv". |
"csv" |
alignments |
Array | Array of alignment strings ("left", "center", "right"). |
["left", "center"] |
prettyPadding |
Boolean | Whether to auto-pad cells with spaces for clean source code. Default true. |
true |
API Request Payload Examples
cURL
curl -X POST https://blueutils.com/api/markdown/table-generator \
-H "Content-Type: application/json" \
-d '{
"text": "Name, Role\nAlice, Engineer",
"format": "csv"
}'Python
import requests
url = "https://blueutils.com/api/markdown/table-generator"
payload = {
"text": "Name, Role\nAlice, Engineer",
"format": "csv"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String jsonPayload = """
{
"text": "Name, Role\\nAlice, Engineer",
"format": "csv"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/markdown/table-generator"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}API Response Parameters
| Name | Type | Description | Example |
|---|---|---|---|
isValid |
Boolean | Indicates whether table generation succeeded. | true |
markdownTable |
String | Formatted GitHub Markdown table string. | "| Name | Role |\n| :--- | :--- |\n| Alice | Engineer |" |
rowsCount |
Number | Total number of data rows in table. | 1 |
colsCount |
Number | Total number of columns in table. | 2 |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"markdownTable": "| Name | Role |\n| :---- | :------- |\n| Alice | Engineer |",
"csvExport": "\"Name\",\"Role\"\n\"Alice\",\"Engineer\"",
"rowsCount": 1,
"colsCount": 2
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"error": "Invalid input: Text parameter is required."
}Rate Limit Exceeded Response (HTTP 429 Too Many Requests)
{
"error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}Why use an API to generate Markdown Tables?
Integrating the Markdown Table Generator API into CI/CD pipelines and GitHub Actions offers key benefits:
- Automated Pull Request Reports: Convert build summary JSON/CSV artifacts into formatted GFM markdown tables for GitHub PR comments.
- AI Agent Tool Calling: Gives AI agents a deterministic tool to convert database rows into clean markdown tables without formatting errors.
Native Usage
How to generate markdown tables programmatically across environments:
Node.js (JavaScript)
function arrayToMarkdownTable(headers, rows) {
const headerStr = `| ${headers.join(' | ')} |`;
const sepStr = `| ${headers.map(() => ':---').join(' | ')} |`;
const rowStrs = rows.map(r => `| ${r.join(' | ')} |`);
return [headerStr, sepStr, ...rowStrs].join('\n');
}
console.log(arrayToMarkdownTable(['Name', 'Role'], [['Alice', 'Engineer']]));Python
def csv_to_markdown(csv_lines):
rows = [line.split(',') for line in csv_lines]
header = f"| {' | '.join(rows[0])} |"
sep = f"| {' | '.join([':---'] * len(rows[0]))} |"
data = [f"| {' | '.join(r)} |" for r in rows[1:]]
return '\n'.join([header, sep] + data)
print(csv_to_markdown(["Name,Role", "Alice,Engineer"]))Java
public class MarkdownTableBuilder {
public static String buildTable(String[] headers, String[][] rows) {
StringBuilder sb = new StringBuilder();
sb.append("| ").append(String.join(" | ", headers)).append(" |\n");
sb.append("| ");
for (int i = 0; i < headers.length; i++) {
sb.append(":---").append(i == headers.length - 1 ? "" : " | ");
}
sb.append(" |\n");
for (String[] row : rows) {
sb.append("| ").append(String.join(" | ", row)).append(" |\n");
}
return sb.toString();
}
public static void main(String[] args) {
String[] headers = {"Name", "Role"};
String[][] rows = {{"Alice", "Engineer"}};
System.out.println(buildTable(headers, rows));
}
}