Convert table data between different formats (MySQL, CSV, JSON, Markdown, HTML, SQL, Excel, XML, LaTeX, MediaWiki, TWiki, templates)
Convert table data between different formats using the tableconvert command line tool.
Multiple ways to use tableconvert:
tableconvert input.csv output.json
tableconvert -i input.csv -o output.json
tableconvert --from csv --to json --file input.csv
tableconvert --from=markdown --to=csv --file=input.md --result=output.csv
cat input.md | tableconvert --from=markdown --to=csv
tableconvert input.csv output.md --bold-header --align=l,c,r
tableconvert input.csv output.json --transpose --capitalize
Common file extensions:
.md, .markdown = markdown.csv = csv.json = json.jsonl, .jsonlines = jsonl.sql = sql.html, .htm = html.xml = xml.xlsx, .xls = excel.tex, .latex = latex.tmpl, .template = template.wiki = mediawiki.twiki = twiki.txt = must specify format explicitlytableconvertConvert table data from one format to another.
Basic Options:
--from={FORMAT} or -f={FORMAT}: Source format (auto-detected from file if omitted)--to={FORMAT} or -t={FORMAT}: Target format (auto-detected from file if omitted)--file={PATH} or --input={PATH} or -i={PATH}: Input file path (optional, uses stdin if omitted)--result={PATH} or --output={PATH} or -o={PATH}: Output file path (optional, uses stdout if omitted)--verbose or -v: Enable verbose outputQuick Options:
-h, --help: Show help message--help-formats: Show all supported formats and their parameters--help-format={FORMAT}: Show parameters for a specific format--mcp: Run as MCP (Model Context Protocol) serverGlobal Transformations:
--transpose: Swap rows and columns--delete-empty: Remove empty rows--deduplicate: Remove duplicate rows--uppercase: Convert all text to UPPERCASE--lowercase: Convert all text to lowercase--capitalize: Capitalize first letter of each cellExamples:
# Auto-detect (simplest)
tableconvert input.csv output.json
# Short flags
tableconvert -i input.csv -o output.json
# Space-separated
tableconvert --from csv --to json --file input.csv
# With options
tableconvert --from=csv --to=markdown --file=input.csv --align=l,c,r --bold-header
# With transformations
tableconvert input.csv output.json --transpose --capitalize
tableconvert --help-formatsGet information about supported formats and their parameters.
Example:
tableconvert --help-formats
Or for a specific format:
tableconvert --help-format=markdown
| Format | Description | Common Use |
|---|---|---|
| mysql | MySQL query output | Database schema |
| csv | Comma-separated values | Spreadsheet data |
| json | JSON (object, 2d, column, keyed modes) | API data |
| jsonl | JSON Lines | Streaming data |
| markdown | Markdown tables | Documentation |
| html | HTML tables | Web pages |
| sql | SQL INSERT statements | Database imports |
| excel | Excel files | Spreadsheet files |
| xml | XML format | Structured data |
| latex | LaTeX tables | Academic papers |
| mediawiki | MediaWiki tables | Wiki content |
| twiki | TWiki/TracWiki format | Wiki content |
| template | Custom templates | Custom output |
Format-specific options are passed as flags without values (true) or with values:
--align=l,c,r: Text alignment (l, c, r) - columns separated by comma--bold-header: Make header bold--bold-first-column: Bold first column--escape: Escape Markdown characters--pretty: Pretty-print with calculated column widths (default: true)--first-column-header: Use first column as headers--bom: Add Byte Order Mark--delimiter=TAB: Value delimiter (COMMA, TAB, SEMICOLON, PIPE, SLASH, HASH)--format=object: Output format (object, 2d, column, keyed)--minify: Minify JSON output--parsing-json: Parse input as JSON--one-insert: Multiple rows in one INSERT--replace: Use REPLACE instead of INSERT--dialect=mysql: SQL dialect (none, mysql, oracle, mssql, postgresql)--table=tablename: Table name--first-column-header: Use first column as headers--div: Use div instead of table--minify: Minify HTML--thead: Include thead/tbody tags--first-column-header: Use first column as headers--sheet-name=Sheet1: Excel sheet name--auto-width: Auto-adjust column widths--text-format: Force text format (default: true)--bold-first-column: Bold first column--bold-first-row: Bold first row--borders=1111,1111: Border style--caption="Table Caption": Table caption--escape: Escape LaTeX characters (default: true)--ht: Place here or top of page--label=table:label: Table label--location=above: Caption location (above, below)--mwe: Minimal working example--table-align=centering: Table alignment (centering, raggedleft, raggedright)--text-align=l: Text alignment (l, c, r)--first-row-header: Use first row as headers--minify: Minify MediaWiki table--sort: Make table sortable--minify: Minify XML--root-element=dataset: Root element tag--row-element=record: Row element tag--declaration: Include XML declaration (default: true)--template=file.tmpl: Template file path--style=box: Table style (box, plus, dot, bubble)Apply these to any format conversion:
--transpose: Swap rows and columns--delete-empty: Remove empty rows--deduplicate: Remove duplicate rows--uppercase: Convert all text to UPPERCASE--lowercase: Convert all text to lowercase--capitalize: Capitalize first letter of each cellExample with transformations:
tableconvert --from=csv --to=json --file=input.csv --uppercase --deduplicate
tableconvert mysql.txt output.md --bold-header
tableconvert input.csv output.json --minify --format=object
tableconvert input.sql output.csv --table=users --capitalize
tableconvert --help-format=markdown
tableconvert -i data.csv -o data.json -v
--from/--totableconvert --help-formats to see all available options for a formatdocs/arguments.md are supportedConverting database schema (auto-detect):
tableconvert schema.txt output.md --bold-header --escape
Creating SQL inserts from data:
tableconvert data.csv output.sql --table=users --one-insert --dialect=mysql
Generating HTML tables:
tableconvert data.json output.html --thead --minify=false
Excel to Markdown for docs:
tableconvert data.xlsx output.md --bold-header --align=l,c,r
Quick pipe conversion:
cat data.csv | tableconvert --from csv --to json --uppercase