You've got a CSV file. You need JSON. Maybe it's for a REST API, a configuration file, a NoSQL database, or a front-end app that reads JSON directly. Here's how to do the conversion correctly — including the parts that most converters get wrong.

What CSV to JSON conversion actually does

A CSV file is fundamentally a flat table: rows and columns, every row has the same fields. JSON is a hierarchical key-value format. Converting between them means turning each row into a JSON object, using the header row as the keys.

Given this CSV:

name,age,city
    Alice,32,New York
    Bob,28,London

The natural JSON output is an array of objects:

[
    { "name": "Alice", "age": 32, "city": "New York" },
    { "name": "Bob",   "age": 28, "city": "London"   }
    ]

Simple enough. But there are decisions to make: Should numeric values stay as strings or become actual JSON numbers? Should you nest by a key column? How do you handle empty cells? These choices depend on what you're doing with the JSON.

Converting in your browser with CSV Splitter Online

CSV Splitter Online has a CSV ↔ JSON tab that handles conversion without uploading your file to any server.

Step 1

Switch to the CSV ↔ JSON tab

Go to csvsplitteronline.com and click "CSV ↔ JSON" in the tool mode bar. You'll see a drop zone for your file and output options.

Step 2

Drop your CSV, TSV, or XLSX file

CSV Splitter Online reads all three formats. Drop your file and the first few rows of parsed data will appear in a preview. Check that the columns look right — if you see garbled headers or data in the wrong column, your file might have a delimiter issue (tabs vs commas).

Step 3

Choose your output structure

Two main options: Array of objects is the most common — each row becomes a JSON object with the headers as keys, and all objects are wrapped in an array. Nested by key turns one of your columns into the top-level key and each row's data becomes the value at that key — useful when you need a lookup table or dictionary structure.

Step 4

Enable number coercion if needed

By default, all CSV values are strings — "32" stays as "32" in the JSON. Enable "Auto-convert numbers" and values that are valid numbers become actual JSON numbers: "age": 32 instead of "age": "32". Enable this if the consuming system expects numeric types for arithmetic, sorting, or comparisons.

Step 5

Preview and download

The first few objects of your JSON output appear in the preview pane. If it looks correct, download the .json file.

The type coercion question

This is the decision that trips up most CSV-to-JSON conversions. CSV stores everything as text — there's no distinction between the string "42" and the number 42. JSON has explicit number and boolean types. When converting, you need to decide which columns should become which type.

The safe default is to keep everything as strings — it's lossless and can't produce incorrect type conversions. The problem is that downstream code consuming your JSON might expect age: 28 (a number) and break when it gets age: "28" (a string), especially in JavaScript where "28" + 1 === "281".

CSV Splitter Online's auto-number-coercion converts any value that parseFloat() correctly identifies as a number. This handles integers, decimals, and negative numbers. It doesn't touch values that look numeric-ish but aren't — like phone numbers, ZIP codes, or product SKUs that start with digits. Those stay as strings.

Leading zeros disappear with number coercion. ZIP codes like "07030" become 7030. Product codes like "00142" become 142. Phone numbers lose country code formatting. If your data has identifiers that start with zeros, disable number coercion or convert specific columns manually.

Nested JSON: when you need a lookup table

Sometimes you need JSON that's keyed by one of your columns rather than a flat array. For example, a product catalog where you want to look up products by SKU:

// Array of objects (default)
    [
    { "sku": "A100", "name": "Widget", "price": 9.99 },
    { "sku": "B200", "name": "Gadget", "price": 24.99 }
    ]

    // Nested by key (key column: "sku")
    {
    "A100": { "name": "Widget", "price": 9.99 },
    "B200": { "name": "Gadget", "price": 24.99 }
    }

The second structure lets you do O(1) lookups in JavaScript: catalog["A100"].price instead of searching through an array. Use this when the JSON will be used as a configuration file or lookup table, and the key column has unique values.

If your key column has duplicate values, nesting by key will silently overwrite earlier records with later ones. Only use nested-by-key with columns you're certain are unique — run a deduplication check first if you're not sure.

Handling empty cells

Empty cells in CSV are ambiguous: they could mean "no value", "null", "zero", or "not applicable" depending on context. In JSON you have options:

  • Emit empty string: "email": "" — cleaner, always present
  • Emit null: "email": null — semantically correct, but some systems handle null differently from missing keys
  • Omit the key entirely: { "name": "Alice" } with no email key — smallest output, but consuming code needs to check for undefined

CSV Splitter Online outputs empty cells as empty strings by default. If you need nulls, a quick post-process in JavaScript: obj[key] = obj[key] === "" ? null : obj[key].

Converting CSV to JSON with Python

For scripted or bulk conversions:

import pandas as pd
    import json

    df = pd.read_csv('data.csv')

    # Array of objects — most common
    records = df.to_dict(orient='records')
    with open('output.json', 'w') as f:
    json.dump(records, f, indent=2)

    # Nested by key (e.g. by 'sku' column)
    nested = {row['sku']: {k: v for k, v in row.items() if k != 'sku'}
    for row in records}
    with open('output_nested.json', 'w') as f:
    json.dump(nested, f, indent=2)

The built-in Python approach without pandas:

import csv
    import json

    with open('data.csv', newline='', encoding='utf-8') as f:
    reader = csv.DictReader(f)
    records = list(reader)

    with open('output.json', 'w', encoding='utf-8') as f:
    json.dump(records, f, indent=2, ensure_ascii=False)

csv.DictReader uses the header row as keys automatically. ensure_ascii=False keeps special characters (accented letters, etc.) readable in the output file rather than escaping them to \u00e9.

Converting JSON back to CSV

CSV Splitter Online also handles the reverse: paste JSON into the JSON tab and get a CSV out. This works for arrays of flat objects — nested JSON needs to be flattened first.

In Python: pd.DataFrame(records).to_csv('output.csv', index=False) — if your JSON is an array of objects with consistent keys, pandas flattens it automatically.

Common problems and fixes

ProblemCauseFix
Numbers showing as stringsAuto-coercion disabledEnable "Convert numbers" in CSV Splitter Online, or cast types in code after import
ZIP codes losing leading zerosAuto-coercion treating them as numbersDisable coercion, or explicitly cast ZIP column to string post-conversion
Garbled characters (é instead of é)Wrong encodingSave source CSV as UTF-8, use encoding='utf-8' in Python
Duplicate keys in nested outputKey column has duplicate valuesDeduplicate first on the key column
JSON too large for your use caseIncluded unnecessary columnsFilter columns in CSV Splitter Online before converting

Convert your CSV to JSON now

Drop your file, choose array or nested output, enable number coercion if you need it. Download in seconds. No upload, no account.

Try CSV Splitter Online free →

Frequently asked questions

Can CSV Splitter Online handle XLSX to JSON conversion?

Yes — drop an XLSX file on the CSV ↔ JSON tab and CSV Splitter Online reads the first sheet and converts it to JSON. The output is identical to what you'd get from a CSV conversion of the same data.

What's the maximum file size for CSV to JSON conversion?

No hard limit — it depends on your device's memory. A 50 MB CSV with straightforward data converts in a few seconds on most computers. The JSON output is typically 2–4x the size of the CSV because of the repeated key names in each object. A 50 MB CSV might produce a 150 MB JSON file. Keep that in mind if you're hitting memory limits.

My JSON needs to be minified (no whitespace). Can I do that?

CSV Splitter Online outputs compact JSON (no extra whitespace) by default. If you need pretty-printed JSON with indentation, open the file in any text editor and reformat — VS Code formats JSON with Shift+Alt+F on Windows.

Can I convert multi-sheet Excel to JSON?

CSV Splitter Online reads the first sheet only. For multi-sheet conversions, use Python: xl = pd.ExcelFile('file.xlsx'); data = {sheet: xl.parse(sheet).to_dict('records') for sheet in xl.sheet_names} — this produces a JSON object with one key per sheet name.

Ready to try it?

Use our free, browser-based CSV tools to apply what you've just learned — no upload, no signup.

Open CSV ↔ JSON →