Tutorial · 5 min read
How to Convert CSV to JSON with Nested Keys and Custom Delimiters
CSV is everywhere — database exports, spreadsheets, logs. But when you need to work with APIs or structured data, JSON is the format that counts. The challenge is mapping flat CSV columns into clean, nested JSON objects. This guide shows how to use the CSV to JSON Converter to do it in seconds, with real-time editing and no data leaving your browser.
The Problem with Flat CSV to JSON
A typical CSV export has columns like name, contact.email, contact.phone, and address.city. That dot notation is the convention for representing nested fields in a flat row:
name,contact.email,contact.phone,address.city Alice,alice@example.com,123-456-7890,Beijing Bob,bob@example.com,,Shanghai
The desired JSON output should group related fields under their parent objects instead of keeping dot-separated keys. A CSV to JSON converter with nested key support handles this automatically.
1. Paste and Parse — The Basic Conversion
Getting started takes 10 seconds:
- Open the CSV to JSON Converter.
- Paste your CSV data into the left panel, or upload a
.csvfile. - The tool parses it instantly into an editable table on the right.
- The JSON output appears below the table, updating in real time.
The result is an array of objects with flat keys. Each CSV row becomes one JSON object:
[
{
"name": "Alice",
"contact.email": "alice@example.com",
"contact.phone": "123-456-7890",
"address.city": "Beijing"
}
]
This works fine for simple cases, but the dot keys aren't ideal for APIs. That's where Unflatten Keys comes in.
2. Enable Unflatten Keys for Nested JSON
Toggle the Unflatten Keys option in the configuration bar. The tool automatically detects dot-separated column headers and nests them into proper JSON objects:
[
{
"name": "Alice",
"contact": {
"email": "alice@example.com",
"phone": "123-456-7890"
},
"address": {
"city": "Beijing"
}
}
]
This mirrors how APIs typically return data, making it perfect for feeding into databases, REST APIs, or other tools. The preview updates instantly so you can verify the structure before downloading.
3. Handling Different Delimiters
Not all CSV files use commas. The converter supports five delimiter modes:
| Mode | Use Case |
|---|---|
| Auto | Detects delimiter automatically — works for most files |
| Comma | Standard CSV format |
| Tab | TSV files or clipboard data from Excel |
| Semicolon | European locale CSV (decimal comma regions) |
| Pipe | Data with commas inside fields (e.g., addresses) |
Select the delimiter from the config bar. The table and JSON output update immediately to reflect the change.
4. Custom Header Row Behavior
By default, the first row is treated as headers and becomes JSON keys. But CSV files vary:
- With Header Row (default): First row = JSON keys, remaining rows = values. You get an array of named objects.
- Without Header Row: All rows become values. The tool auto-generates keys (
col_0,col_1, ...) or you can customize them later by editing the table.
Toggle the Header Row checkbox in the config bar. The JSON output changes shape instantly — try it both ways to see which format fits your use case.
5. Pretty vs Compact JSON Output
The converter offers two output formats:
- Pretty: Formatted with indentation — easy to read and debug. Best for humans.
- Compact: Minified single-line JSON. Best for API payloads and storage.
Switch between them with the Output Format dropdown. The right panel preview updates instantly so you can pick the version that fits your pipeline.
Try the Free CSV to JSON Converter
Paste CSV, edit cells, see JSON update in real time. Nested keys, custom delimiters, and no server uploads.
Convert CSV to JSON Now →Best Practices for CSV to JSON Conversion
- Clean your CSV first. Remove extra whitespace, fix inconsistent quoting, and check for empty rows. Use the JSON to CSV guide for round-trip quality tips.
- Use dot notation for nesting. Name your CSV columns like
user.nameanduser.email, then enable Unflatten Keys. The tool nests them automatically. - Verify with the live preview. The JSON output updates as you type — check it before downloading. If the structure looks wrong, tweak the config and see the change immediately.
- Match delimiters to your data. If your CSV has commas inside quoted fields (e.g., addresses), switch to Tab or Pipe delimiter to avoid parsing errors.
- For Excel sources, convert to XLSX instead. If you have an Excel file, use Excel to JSON directly — no intermediate CSV conversion needed.
Frequently Asked Questions
How do I convert CSV to JSON online?
Paste or upload your CSV data into the CSV to JSON Converter. The tool parses it into an editable table in real time. Configure delimiters, header rows, and nested key mapping, then click download to export as JSON.
Can I convert CSV to nested JSON with dot notation?
Yes. Enable the Unflatten Keys option in the configuration bar. If your CSV has a column named address.city, it converts to {"address": {"city": "value"}} in the JSON output. Multi-level nesting like user.address.city works too.
Which delimiters does the CSV to JSON converter support?
Auto-detect, Comma, Tab, Semicolon, and Pipe. The Auto mode detects the delimiter automatically. Use Tab for TSV files and Pipe for data with commas inside fields. The preview updates in real time when you switch modes.
Can I edit the data before converting to JSON?
Absolutely. The table preview is fully editable — double-click any cell to change values, add or delete rows. The JSON output updates instantly as you edit. No need to re-upload or re-paste your CSV.
Is my CSV data safe with this converter?
100% safe. All processing happens in your browser using client-side JavaScript. Your data never leaves your computer. The tool works offline once the page is loaded — no server uploads, no storage, no tracking.