Outils · Texte · Convertir un CSV en JSON · Guides · How to Convert a CSV File to a JSON Array (and Back)

How to Convert a CSV File to a JSON Array (and Back)

3 min de lecture

Here's the actual process for converting between CSV and JSON with CSV to JSON, in either direction.

Paste, pick a direction, and get a live-updating result A pipeline: paste CSV or JSON, pick a direction with the toggle, and see the converted result update live. Paste text Pick direction CSV ↔ JSON Live result + Copy
The result updates as you type - there's no separate Convert button to click.

Step 1 - pick a direction

A toggle at the top switches between "CSV to JSON" and "JSON to CSV." Pick whichever matches what you're pasting.

Step 2 - paste your data

For CSV to JSON, paste CSV text with the first row as your column headers. For JSON to CSV, paste a JSON array of objects - or a single object, which the tool treats as a one-item array automatically. The converted result appears immediately in the output panel as you type or paste, with no separate button to click.

Step 3 - check the result and copy it

CSV to JSON: every row becomes one object, keyed by your header row; every value stays exactly what was in the cell, as a string. A missing trailing cell in a row is padded to an empty string rather than throwing an error; an extra cell beyond the header width is dropped. JSON to CSV: the header row is built from the union of every object's keys, in the order they first appear, and any cell that needs a comma, quote, or line break gets quoted correctly.

What happens with imperfect input

CSV doesn't really have an "invalid syntax" the way JSON does - an unterminated quote at the end of the file just gets closed gracefully rather than throwing an error, so this direction never shows an error state. JSON to CSV is different: invalid JSON shows the actual parse error, and valid JSON that isn't shaped like an array of objects (a bare number, an array of plain strings) gets a specific message telling you what shape is expected instead.

Nested data in JSON to CSV

If one of your objects has a nested object or array as a value, that value gets serialized as its own JSON string inside that CSV cell, rather than silently dropped or turned into an unhelpful placeholder. It's not pretty, but it's honest - the data survives the round trip even where CSV's flat, row-and-column shape doesn't have a native way to represent it.

Nothing here uploads anywhere

Both directions run entirely inside the browser tab, synchronously, as you paste - there's no server involved at any point.

For why type-guessing and quoted commas trip up other converters, see the background piece. For more on the string-only decision specifically, this guide covers it. Or convert now.

Essayer Convertir un CSV en JSON gratuitement Convertir un CSV en JSON

Outils similaires