FIRST CH TOOLS / 39 CSV ⇄ JSON

CSV/TSV ⇄ JSON Converter

Paste a spreadsheet export on the left to get a JSON array, or paste an API response on the right to get a table — either side converts as you type. The delimiter is detected for you, column names such as stock.qty become nested objects, and values such as 0123 or a 20-digit ID stay text so that no digits are lost.

Type in either box and it converts instantly

CSV / TSV
JSON
0
Data rows
0
Columns
0
Input bytes
0
Output bytes
Checks

    Nothing you paste leaves the browser — the CSV reader and the JSON parser both run on this page, with no external libraries. Loading a file only reads it locally; it is never uploaded. You can also call the tool straight from a URL: /en/csv-json/?csv=a%2Cb%0A1%2C2 or /en/csv-json/?json=%5B%7B%22a%22%3A1%7D%5D&delim=tab

    How to Use

    1. Paste into either boxCSV or TSV on the left becomes JSON on the right; JSON on the right becomes a table on the left. Dropping a file works too.
    2. Say how to read itThe delimiter is detected but can be pinned. Switch the header row, the nesting, the type inference and the BOM to match your data.
    3. Check and copyRagged rows, duplicate headers, values that would lose digits and cells a spreadsheet would execute all appear under Checks.

    About This Tool

    CSV and JSON hold the same tabular data in two notations. CSV opens in any spreadsheet but has no nesting and no types; JSON carries structure and types but is awkward to read as a table. This page exists for the moment you need your own data to move between the two — “open this in Excel”, “post this to an API”, “load this as a fixture”.

    Nesting travels in the column names. A column called stock.qty becomes {"stock":{"qty":…}}, and tags.0 / tags.1 become an array; tags[0] is read the same way. Because the reverse direction flattens with the same rule, a round trip through CSV returns the original structure. When a name is already taken by a plain value, that column is left flat and reported in the checks.

    Type inference is decided by round trip. Plenty of values look numeric yet change when converted: 0123, +1, 1.50, integers past 2^53. Each candidate is converted to a number and back to text, and it is only written as a number when the result is character-for-character identical. That is why postcodes, phone numbers and version strings survive. true, false and null are recognised as well; turn the option off to keep every cell as a string.

    Files written by Excel are read as they are: UTF-8 with a BOM, CRLF line endings, quoted cells containing line breaks and "" escapes. Rows with broken quoting are still read — as literal characters — and the lines that look wrong are listed. Being able to read a real-world file and point at the damage is more useful than refusing it on principle.

    JSON syntax errors are reported with a line and a column. Browser JSON.parse messages differ between engines, so the parser here is written out in full: it prints the two lines either side of the problem and points at the column with ^. Input that is not an array (a single object, or {"data":[…]} wrapping one) and JSON Lines are both accepted.

    Related tools: JSON ⇄ YAML for configuration files, Markdown Table for pasting a table into documentation, Test Data Generator for making rows from scratch, and Encoding Converter for character encodings. This page is for moving data you already have from one notation to the other.

    From AI Agents

    This conversion logic is also available as the csv_convert tool of the @first-ch/tools-mcp MCP (Model Context Protocol) server, so an AI agent can call it without a browser. It reads and writes files by path, which makes it a natural first step before processing a spreadsheet export. See For AI Agents for setup.

    Install

    claude mcp add firstch-tools -- npx -y @first-ch/tools-mcp

    Examples

    # CSV to a JSON array (delimiter detected, types inferred)
    csv_convert(text="id,name\n1,Alice\n2,Bob")
    
    # Read a CSV file and write the JSON next to it
    csv_convert(path="/tmp/orders.csv", outputPath="/tmp/orders.json")
    
    # JSON to a CSV for Excel (BOM, CRLF)
    csv_convert(direction="json2csv", path="/tmp/items.json", outputPath="/tmp/items.csv", bom=true, newline="crlf")
    
    # TSV with no header row and no type inference
    csv_convert(text="1\t2\n3\t4", delimiter="tab", header=false, types=false)

    Other Tools