# How I turn CSV into JSON without breaking the data

A beginner-friendly guide to CSV and JSON conversion, headers, delimiters, quoted values, data types, and checking the output before using it.

- Date: 2026-09-27
- URL: https://ilham.dev/posts/how-to-turn-csv-into-json-without-breaking-the-data/
- Markdown: https://ilham.dev/posts/how-to-turn-csv-into-json-without-breaking-the-data/index.md
- Tags: csv, json, data, tools
- Reading time: 3 min


CSV is easy to open in a spreadsheet. JSON is easy to use in APIs and code. Moving
between them sounds simple, but small details can break the data.

The [CSV and JSON Converter](/tools/csv-json-converter/) helps convert CSV to JSON
and JSON back to CSV in the browser.

## The simple idea

CSV is a table:

```csv
name,email
Ana,ana@example.com
Budi,budi@example.com
```

JSON can represent the same data as an array of objects:

```json
[
  { "name": "Ana", "email": "ana@example.com" },
  { "name": "Budi", "email": "budi@example.com" }
]
```

The first CSV row usually becomes the JSON field names.

## Step 1: check the header row

A clean CSV should have clear headers:

```csv
name,email,role
```

Avoid empty or duplicate headers if possible. JSON object keys should be meaningful.

Bad:

```csv
name,,name
```

Better:

```csv
name,email,role
```

## Step 2: check the delimiter

Most CSV files use commas, but not all. Some use semicolons or tabs.

Comma-separated:

```csv
name,email
Ana,ana@example.com
```

Semicolon-separated:

```csv
name;email
Ana;ana@example.com
```

If the delimiter is wrong, the converter may treat the whole row as one field.

## Step 3: watch quoted values

CSV values can contain commas if they are quoted:

```csv
name,note
Ana,"likes coffee, tea, and bread"
```

A good converter keeps that note as one value, not three columns.

If your data contains commas, quotes, or line breaks inside cells, inspect the output
carefully.

## Step 4: convert to JSON

Open [CSV and JSON Converter](/tools/csv-json-converter/), paste the CSV, choose the
right delimiter, and convert.

Check the output shape:

```json
[
  {
    "name": "Ana",
    "note": "likes coffee, tea, and bread"
  }
]
```

If the keys look wrong, go back to the header and delimiter.

## Step 5: remember that CSV has weak types

CSV is text. It does not strongly know the difference between:

```text
123
```

and:

```text
"123"
```

Depending on the converter and settings, numbers may stay as strings or become JSON
numbers.

This matters for IDs. A value like this should often stay a string:

```text
00123
```

If it becomes a number, the leading zeros may be lost.

## Step 6: convert JSON back to CSV carefully

JSON arrays of flat objects convert cleanly:

```json
[
  { "name": "Ana", "email": "ana@example.com" }
]
```

Nested JSON is harder:

```json
[
  { "name": "Ana", "address": { "city": "Jakarta" } }
]
```

A table does not naturally contain nested objects. The converter may flatten them or
turn them into JSON text inside a cell.

Check the result before using it in a spreadsheet or import job.

## My CSV/JSON checklist

Before trusting a conversion, I check:

1. Does the CSV have a header row?
2. Is the delimiter correct?
3. Are quoted commas handled correctly?
4. Are row counts correct before and after?
5. Did IDs keep leading zeros?
6. Did empty fields become the expected value?
7. Is the JSON an array of objects?
8. If converting back to CSV, is nested data handled acceptably?

Conversion is not only changing format. It is preserving meaning.
