APIs and apps speak JSON. Spreadsheets, exports and legacy systems speak CSV. Sooner or later you are handed a comma separated file and told the endpoint wants a JSON array, and the gap between the two formats is yours to close. Doing it by hand invites typos; writing a throwaway script for a one-off file is its own chore.
The free CSV to JSON Converter on Ovatly closes that gap in your browser. This guide explains the one decision that shapes the output, the header row, and the one surprise every API consumer meets the first time: every value in the JSON is a string, and that is deliberate.
Contents
- Quick answer
- What the converter produces
- The header decision: objects or arrays of arrays
- Why every value is a string
- Delimiters, quoting and uneven rows
- How to convert CSV to JSON, step by step
- Worked example: a two-row people file
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
To convert CSV to JSON for an API or app: paste your CSV into the CSV to JSON Converter or upload the .csv file, keep the header checkbox on if the first row names your columns, press Convert to JSON, then copy the result or download it as converted.json. With the header on, each row becomes an object keyed by the header names, which is the shape most APIs expect. Expect every value to be a string: the converter never guesses types, so convert numbers on the receiving side if your API needs them as numbers.
What the converter produces
The output is always a JSON array. What changes is what sits inside it. With the header option on, each data row becomes one object, and the header names become the keys. With the header option off, each row becomes an inner array of cell values, in order.
Most APIs and apps want the object form, because a key like "age" survives being read by another developer, a schema or a debugger far better than a bare position in an array. The array form is the right choice when your file genuinely has no header and the consumer already knows the column order by position.
The header decision: objects or arrays of arrays
This is the only real decision in the whole conversion, and it is worth making consciously. If the first row of your file names the columns, leave the header checkbox on. The converter reads those names once and applies them to every row, so a file with thousands of rows still produces consistent objects.
If your file has no header row and you leave the checkbox on by mistake, the first data row will be promoted to keys and silently disappear as data. Check the output's first object against your file's second row: if they match, the setting is right. If the first object looks like data wearing key costumes, turn the header off and convert again.
Why every value is a string
CSV is plain text. It has no number type, no boolean type and no null. When the converter reads the cell 31, all it truly knows is that the file contains the characters 3 and 1. So it writes "31", a string, and it does this for every cell without exception.
This surprises people the first time, because the JSON looks less finished than they hoped. Treat it as a feature, not a gap. A converter that guesses types will eventually guess wrong: it will turn the code 00731 into the number 731 and destroy the leading zeros, or read a date-like string as something it is not. Keeping every value a string means the conversion is lossless and predictable. If your API needs age as a number, convert it on the receiving side, in code you control, where the schema decision belongs. One deliberate conversion in your app beats a thousand silent guesses in a file tool.
Delimiters, quoting and uneven rows
Real CSV files are messier than the name suggests. Many European exports use semicolons as the delimiter because commas serve as decimal points; other files use tabs. The converter detects the delimiter automatically, so you do not need to re-export the file just to convert it.
Quoted fields are handled following the standard CSV quoting rules, so a cell that contains a comma, a quote or even a newline inside quotes stays one cell in the JSON, exactly as a spreadsheet would read it. And when a row has fewer cells than the header, the missing values are padded with empty strings, so every object in the output carries the same set of keys. An API receiving the array never meets a row that is inexplicably missing a field.
How to convert CSV to JSON, step by step
- Open the CSV to JSON Converter and paste your CSV text, or upload the .csv file.
- Set the header checkbox: on if the first row names the columns, off if the file is headerless data.
- Press Convert to JSON.
- Check the first object in the output against your file, then copy the JSON or download it as converted.json.
Worked example: a two-row people file
Take this small CSV with a header row:
name,age
Ana,31
Ben,28
With the header option on, the output is an array of two objects:
[
{
"name": "Ana",
"age": "31"
},
{
"name": "Ben",
"age": "28"
}
]
Two things to notice. The header names became the keys, exactly as written. And the ages are quoted: "31" and "28" are strings, because that is what the CSV actually contains. If the API you are feeding expects numeric ages, that conversion happens in your code after the import, not inside this file.
Limitations and honest tradeoffs
The converter does not infer a schema. It will not nest objects, split a column into two, or rename keys; the JSON mirrors the CSV's flat shape, and reshaping beyond that is your application's job. Because every value is a string, consumers that are strict about types will reject the output until the receiving side converts the fields it cares about.
The header setting also cuts both ways: with it on, the first row is always consumed as names, so a file that mixes a title line above the real header needs that line removed before conversion. And while quoted fields follow the standard rules, a badly broken file with unbalanced quotes cannot be repaired by any converter; fix the export first.
Common mistakes
- Leaving the header on for a headerless file. Your first data row becomes the keys and vanishes as data. Check the first output object.
- Expecting numbers in the output. Every value is a string by design. Convert types on the receiving side, deliberately.
- Re-exporting a semicolon file as commas first. Unnecessary: the delimiter is detected automatically.
- Hand-editing the JSON afterwards. If the output shape is wrong, the fix is almost always the header setting or the source file, not manual patching.
FAQs
Why are all the values in quotes in the JSON output? CSV has no data types, so every cell is text. The converter keeps values as strings exactly as written rather than guessing that 31 should become a number. That protects things like codes with leading zeros, and any number conversion is left for the receiving API or app to do deliberately.
What happens if my CSV has no header row? Turn the header checkbox off. The output is then an array of arrays, one inner array per row, instead of objects keyed by header names.
My file uses semicolons instead of commas. Will it still work? Yes. The delimiter is detected automatically by the parser, so comma, semicolon, tab and other common delimiters work without any setting to change.
What happens to a row with fewer cells than the header? Short rows are padded with empty strings, so every object in the output has the same keys. No row is dropped and no key goes missing.
Is my CSV uploaded to a server? No. The conversion runs in your browser on your device. You paste the CSV or load the file locally, and the JSON is produced without anything being sent anywhere.
Conclusion
Converting CSV to JSON is a two-minute job once the header decision is made: objects when the first row names the columns, arrays when it does not, and strings everywhere because CSV never promised you types. The CSV to JSON Converter handles the delimiters, quoting and ragged rows for you, locally. If the JSON you end up with then fails a stricter check downstream, our guide to why JSON turns out invalid and how to find the error fast is the next step. For more guides in this series, see our Data and JSON Tools guides.
References
- RFC 4180, the common definition of the CSV format and its quoting rules: https://www.rfc-editor.org/rfc/rfc4180
- MDN Web Docs, on working with JSON data in JavaScript: https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Scripting/JSON