CSV to JSON

CSV is what you get out of spreadsheets and database exports; JSON is what APIs, JavaScript frontends and modern config files want. This converter takes a CSV with a header row and produces an array of JSON objects where each header becomes a key and each data row becomes one object. The output is pretty-printed with unescaped Unicode and forward slashes, so you can paste it straight into a Postman request or a JS file.

How the CSV becomes JSON

  1. 1

    Paste the CSV

    It must contain at least a header row and one data row; the tool returns an error otherwise.

  2. 2

    Header row sets the keys

    Row 1 is parsed with `str_getcsv` and the column names, trimmed of whitespace, become JSON keys.

  3. 3

    Each data row becomes an object

    Values are aligned with headers by position. Missing cells are emitted as empty strings.

  4. 4

    Copy the pretty JSON

    Formatted with JSON_PRETTY_PRINT, JSON_UNESCAPED_UNICODE and JSON_UNESCAPED_SLASHES so it reads well in any editor.

How the conversion handles types and edge cases

CSV is fundamentally typeless: every cell is a string. JSON has real types. The converter errs on the safe side and leaves every value as a JSON string, you will never get a number silently turned into text, or a zero-prefixed ID losing its leading zeros.

Example

Input CSV:

name,age,email
Alice,30,alice@example.com
Bob,25,bob@example.com

Output JSON:

[
  { "name": "Alice", "age": "30", "email": "alice@example.com" },
  { "name": "Bob",   "age": "25", "email": "bob@example.com"   }
]

Note that age is a string, not a number. If you need numeric types, either post-process with Number(row.age) in JavaScript, or use the CSV to JSON Converter which has more options for typing.

Edge cases

Situation Behaviour
Empty data row Skipped silently, no empty object in the output.
Row shorter than header Missing fields emitted as empty strings.
Row longer than header Extra cells are dropped.
Duplicate header names Later keys overwrite earlier ones in the resulting object.
Header with surrounding whitespace Trimmed before being used as a key.

When to pick the other CSV-to-JSON tool

This is the straightforward converter, sensible defaults, no switches. Reach for the CSV to JSON Converter when you need to pick a non-comma delimiter, disable the header row, or toggle compact versus pretty output.

Frequently Asked Questions

Not from this simple converter. Every value is emitted as a JSON string, which preserves IDs like 00123 and decimals like 1.50 exactly as they appear. Post-process with Number() or parseFloat() in your consumer, or use the other CSV to JSON Converter for extra options.

This tool requires one, it uses the header names as JSON keys. If your file has no header, add a row like col1,col2,col3 at the top, or switch to the CSV to JSON Converter which has a toggle to disable headers.

Unicode characters are left unescaped (accents, CJK, emoji all appear literally in the output). Forward slashes are not escaped either, so URLs look natural. Double quotes inside values are properly escaped as \".

Yes. The CSV is sent to our server so the JSON can be generated. It is not stored and it is not added to the page link.

Related Tools