CSV Converter

Convert CSV data to JSON, HTML tables, SQL statements, XML, Markdown, and more.

CSV Input

Preview

nameagecity
John30New York
Jane25Los Angeles
Bob35Chicago

Output Format

Output

[
  {
    "name": "John",
    "age": "30",
    "city": "New York"
  },
  {
    "name": "Jane",
    "age": "25",
    "city": "Los Angeles"
  },
  {
    "name": "Bob",
    "age": "35",
    "city": "Chicago"
  }
]

What Is CSV and Why Convert It?

CSV — Comma-Separated Values — is one of the oldest and most universally supported data interchange formats. Virtually every spreadsheet application, database engine, and data pipeline can read or write CSV, making it the de-facto lingua franca of tabular data. Each line in a CSV file represents one record, and each field within that record is separated by a delimiter character — most commonly a comma, though semicolons, tabs, and pipes are also common in specific regions or industries.

Despite its simplicity, raw CSV is rarely the format you actually need for downstream work. Front-end applications expect JSON, HTML renderers need a table structure, documentation tools like GitHub or Obsidian render Markdown tables, relational databases are loaded with SQL INSERT statements, integrations that talk to older enterprise systems often demand XML, and analytics pipelines frequently prefer TSV (tab-separated values) because tabs never appear in most numeric or name fields.

Converting between these formats by hand is tedious and error-prone. A CSV file with 500 rows means writing 500 INSERT statements or 500 JSON objects manually — one misplaced quote or bracket and the entire import fails. The CSV Converter on this page automates that transformation instantly in your browser, with no data ever leaving your device. Simply paste or type your data, pick a delimiter, indicate whether the first row is a header, choose an output format, and copy the result.

Understanding the underlying logic also helps you choose the right format for each situation. JSON is ideal for APIs and JavaScript-based frontends because it maps naturally to objects and arrays. HTML tables are perfect for embedding data directly in web pages or emails. SQL INSERT statements let you bulk-load data into MySQL, PostgreSQL, SQLite, or any ANSI-SQL-compatible database. XML remains dominant in enterprise and government data exchange. Markdown tables render cleanly in GitHub READMEs, Notion, and Obsidian. TSV is preferred when your data might contain commas inside values, eliminating ambiguity without requiring quote-escaping.

How CSV Parsing Works

The CSV Converter uses a character-by-character parser that correctly handles quoted fields — the most common source of bugs in naive CSV readers. The algorithm maintains an inQuotes flag; when it encounters a double-quote character ("), it toggles the flag. While inQuotes is true, delimiter characters are treated as literal text rather than field separators. This means a field like "New York, NY" is correctly parsed as a single value even though it contains a comma.

Once parsing is complete, the tool identifies headers and data rows based on your First row is header setting. When the checkbox is checked, row 0 becomes the key names for JSON objects, the column headers for HTML/Markdown/SQL, and the element tag names for XML. When unchecked, auto-generated names (column1, column2, …) are used instead.

CSV Row Parsing Logic

for each char in row: if char === '"' → toggle inQuotes; else if char === delimiter AND NOT inQuotes → push field; else → append to current field

Where:

  • inQuotes= Boolean flag — true while inside a quoted field
  • delimiter= Field separator character: comma, semicolon, tab, or pipe
  • current= Accumulator for the current field value

Output Formats Explained

The converter supports six output formats, each suited to a different workflow:

  • JSON — Produces an array of objects where each object's keys come from the header row and values come from the corresponding data cells. This is the standard format for REST APIs, Node.js data files, and frontend data loading. The output is pretty-printed with two-space indentation for readability.
  • HTML Table — Generates a complete <table> element with a <thead> containing header cells and a <tbody> containing data rows. Paste this directly into any HTML page or email template and it renders immediately.
  • Markdown — Outputs a pipe-delimited Markdown table with a separator row of dashes after the header. GitHub, GitLab, Bitbucket, Notion, and Obsidian all render Markdown tables natively. This is the fastest way to include data in documentation.
  • SQL INSERT — Produces one INSERT INTO table_name (...) VALUES (...); statement per data row, with all values single-quoted and internal single quotes escaped by doubling them (the ANSI SQL standard). Paste into any SQL client to bulk-load data.
  • XML — Wraps data in a <data> root element, with each row in a <row> child and each field in an element named after its column header. Suitable for SOAP services, legacy enterprise APIs, and configuration files.
  • TSV — Replaces the delimiter with tab characters. TSV is unambiguous when values contain commas, and many analytics tools (R, Python pandas, Excel) accept TSV files natively.

All six transformations happen client-side in real time — there is no server round-trip, no file upload, and no account required. The preview table shows up to five rows so you can visually verify the parse result before copying the output.

Choosing the Right Delimiter

The four supported delimiters cover nearly every real-world CSV variant you will encounter:

Delimiter Common Use Case When to Choose
Comma (,) Standard CSV, Excel exports, Google Sheets Default choice for English-locale data
Semicolon (;) European locales, SAP exports When commas appear in numeric fields (1.234,56)
Tab TSV files, database exports, R/Python data When values contain commas or semicolons
Pipe (|) Log files, Unix utilities, some CRM exports When both commas and tabs appear in data

If your conversion produces unexpected extra columns or merged fields, the delimiter is almost always the culprit. Try each option in turn while watching the preview table — the correct delimiter will produce clean, aligned columns with no stray empty fields.

Practical Use Cases and Workflows

The CSV Converter fits naturally into dozens of everyday developer and analyst workflows:

  • Database seeding: Export sample data from Google Sheets, convert to SQL INSERT statements, and paste directly into a migration file or SQL client to seed a development database in seconds.
  • API mock data: Convert a spreadsheet of test cases to JSON and import it into tools like Postman, Insomnia, or a Jest test fixture file.
  • Documentation tables: Copy tabular data from a report or spreadsheet, convert to Markdown, and paste into a GitHub README or wiki page without manually aligning pipe characters.
  • Email reports: Convert weekly metrics to an HTML table and embed it in an HTML email template — no design tool required.
  • Data migration: When moving data between systems that use different file formats, use the converter as a middle step: export CSV from the source, convert to XML or JSON for the target's import API.
  • Legacy system integration: Older ERP and government systems commonly accept only XML. The converter produces standards-compliant XML with UTF-8 declaration, ready for direct upload.
  • Analytics preprocessing: Convert comma-delimited exports to TSV before loading into R's read.table() or Python's pandas.read_csv(sep=' ') to sidestep quoting complications.

Because processing happens entirely in your browser, you can safely convert sensitive or confidential datasets — financial records, PII, proprietary business data — without uploading them to any third-party server. The tool is stateless and leaves no trace beyond your clipboard.

Worked Examples

CSV to JSON

Problem:

Convert a 3-row CSV with headers name, age, city into JSON format using a comma delimiter.

Solution Steps:

  1. 1Paste the CSV input: name,age,city\nJohn,30,New York\nJane,25,Los Angeles\nBob,35,Chicago
  2. 2Select delimiter: Comma (,) and check 'First row is header'.
  3. 3Choose output format: JSON. The parser reads row 0 as keys: ['name','age','city'] and maps each subsequent row to an object.
  4. 4Result is an array of objects: [{"name":"John","age":"30","city":"New York"}, {"name":"Jane","age":"25","city":"Los Angeles"}, {"name":"Bob","age":"35","city":"Chicago"}]

Result:

[{"name":"John","age":"30","city":"New York"},{"name":"Jane","age":"25","city":"Los Angeles"},{"name":"Bob","age":"35","city":"Chicago"}]

CSV to SQL INSERT Statements

Problem:

Generate SQL INSERT statements from a product CSV with columns id, product, price for 3 rows.

Solution Steps:

  1. 1Input CSV: id,product,price\n1,Widget A,9.99\n2,Gadget B,24.99\n3,Tool C,4.49
  2. 2Select delimiter: Comma (,), check 'First row is header', choose output: SQL INSERT.
  3. 3Parser maps headers to column list: (id, product, price). Each data row is single-quoted and internal apostrophes are doubled per ANSI SQL.
  4. 4Three INSERT statements are produced: INSERT INTO table_name (id, product, price) VALUES ('1', 'Widget A', '9.99'); and so on for each row.

Result:

INSERT INTO table_name (id, product, price) VALUES ('1', 'Widget A', '9.99'); INSERT INTO table_name (id, product, price) VALUES ('2', 'Gadget B', '24.99'); INSERT INTO table_name (id, product, price) VALUES ('3', 'Tool C', '4.49');

Semicolon-Delimited CSV to Markdown Table

Problem:

A European locale export uses semicolons: Country;Population;Capital. Convert to Markdown.

Solution Steps:

  1. 1Paste input: Country;Population;Capital\nFrance;68000000;Paris\nGermany;84000000;Berlin\nSpain;47000000;Madrid
  2. 2Change delimiter to Semicolon (;). Check 'First row is header'. Choose output: Markdown.
  3. 3Header row becomes: | Country | Population | Capital |. A separator row of | --- | --- | --- | is inserted below.
  4. 4Each data row becomes a pipe-delimited line: | France | 68000000 | Paris | — ready to paste into any Markdown document.

Result:

| Country | Population | Capital | | --- | --- | --- | | France | 68000000 | Paris | | Germany | 84000000 | Berlin | | Spain | 47000000 | Madrid |

CSV to XML

Problem:

Convert a two-row employee CSV to XML for an enterprise system integration.

Solution Steps:

  1. 1Input: employee_id,first_name,department\nE001,Alice,Engineering\nE002,Bob,Marketing
  2. 2Select delimiter: Comma, check header row, choose output: XML.
  3. 3Parser wraps all rows in a <data> root element. Each row becomes a <row> element with children named after column headers.
  4. 4Output: <?xml version="1.0" encoding="UTF-8"?><data><row><employee_id>E001</employee_id><first_name>Alice</first_name><department>Engineering</department></row>...</data>

Result:

<?xml version="1.0" encoding="UTF-8"?> <data> <row> <employee_id>E001</employee_id> <first_name>Alice</first_name> <department>Engineering</department> </row> <row> <employee_id>E002</employee_id> <first_name>Bob</first_name> <department>Marketing</department> </row> </data>

Tips & Best Practices

  • Always glance at the Preview table before copying output — it catches delimiter mismatches instantly without reading the raw output.
  • For SQL output, replace table_name globally with your real table name in a text editor using Find & Replace (Ctrl+H / Cmd+H) before running the statements.
  • When values contain your delimiter character, wrap them in double quotes in the source CSV: e.g. "London, UK" for comma-delimited files.
  • TSV output is the safest choice for data destined for pandas or R, since neither format requires quote-escaping for tab-delimited fields.
  • To create a JSON data file for a Next.js or React project, convert your spreadsheet to JSON here and save the output as a .json file — no backend needed.
  • For XML output used in enterprise APIs, verify that your column header names are valid XML element names (no spaces, no leading digits). Rename headers in the CSV before converting if needed.
  • If your European locale CSV uses semicolons and decimal commas (e.g. 1.234,56), convert to JSON or TSV first, then handle numeric parsing in your application code rather than trying to fix it in the CSV step.
  • Use the Markdown output to quickly add data tables to GitHub READMEs, pull request descriptions, or Confluence pages without installing any additional tool.

Frequently Asked Questions

No. All parsing and conversion happens entirely in your browser using JavaScript. Your data never leaves your device and is never sent to any server. This makes the tool safe to use with sensitive, confidential, or proprietary datasets including financial records and personally identifiable information.
Wrap the value in double quotes in your CSV, for example: John,"New York, NY",30. The parser's quote-aware logic detects the opening quote, sets an inQuotes flag, and treats the comma inside as a literal character rather than a field separator. The resulting field value will be New York, NY without the surrounding quotes.
Yes. Uncheck the 'First row is header' checkbox. When unchecked, every row (including the first) is treated as a data row, and columns are automatically named column1, column2, column3, and so on. These auto-generated names appear as JSON keys, SQL column names, and XML element names in the output.
The tool uses table_name as a placeholder because it has no way to know your actual database table name. After copying the SQL output, use your text editor's find-and-replace to substitute table_name with your real table name before running the statements in your database client.
The most common cause is a mismatched delimiter. If your file uses semicolons but the delimiter is set to comma, each row will appear as a single column. Check your source file in a plain-text editor to see which character separates the fields, then select the matching delimiter option. Also verify that the 'First row is header' setting matches your data.
The current implementation splits input on newline characters first and then parses each line independently, so multi-line fields enclosed in quotes are not fully supported. For best results, ensure each record occupies exactly one line. Multi-line CSV is an edge case in the RFC 4180 specification and is rarely needed in practice.
Yes. With 'First row is header' unchecked, the tool generates auto-named headers (column1, column2, …). In HTML output these become <th> cells, and in XML output they become element tag names. The output is fully valid; you can manually rename the tags or headers in your text editor after copying.

Sources & References

Last updated: 2026-06-05

💡

Help us improve!

How would you rate the CSV Converter?

<>

Editorial Note

MyCalcBuddy Editorial Team

This page is maintained as an educational calculator reference.

Source

Formula Source: Standard Mathematical References

by Various

UpdatedLast reviewed: May 2026
CheckedFormula checks are based on standard references and internal QA review.