CSV to JSON — How to Convert CSV Files to JSON
CSV and JSON are two of the most widely used data formats in the world — but they serve very different purposes. CSV (Comma-Separated Values) is a simple tabular format favored by spreadsheets and data exports. JSON (JavaScript Object Notation) is the language of the web: APIs, databases, and modern applications run on it.
The problem? You often receive data as a CSV — from a CRM export, a spreadsheet, a database dump — and need it in JSON format for your app, API, or workflow. This guide shows you exactly how to convert CSV to JSON, explains what happens to your data during conversion, and walks you through FileNaut's free browser-based converter — no uploads, no sign-up, nothing leaving your computer.
What Is CSV?
CSV stands for Comma-Separated Values. It's a plain text format where the first row typically contains column headers, each subsequent row represents a data record, and fields are separated by commas (or sometimes semicolons or tabs).
CSV is universal — virtually every spreadsheet app, database, and data tool can export CSV. But it has no native support for nested data, arrays, or mixed types.
What Is JSON?
JSON stands for JavaScript Object Notation. Despite the name, it's language-agnostic and is used everywhere. JSON structures data as objects (key-value pairs inside {}), arrays (ordered lists inside []), and nested structures.
JSON is required by virtually every REST API, used natively in JavaScript/Node.js, and is the default format for tools like MongoDB, Firebase, and most modern databases.
How CSV to JSON Conversion Works
The conversion logic is straightforward:
- Parse the first row as the list of field names (keys)
- Parse each subsequent row as a data record
- Map each value to its corresponding key from the header row
- Output an array of JSON objects — one per row
The result is an array of objects where each object represents one CSV row, and each key corresponds to a column header.
What about data types? CSV has no native type system — everything is a string. A good converter will optionally cast numeric-looking strings to actual numbers, or leave them as strings (safer by default).
How to Convert CSV to JSON with FileNaut
FileNaut's CSV to JSON converter runs entirely in your browser — your data never leaves your device.
- Open the tool — go to filenaut.com/csv-to-json
- Input your CSV — paste directly into the text area, or click "Upload CSV" to select a file
- Configure options — set delimiter (comma, semicolon, or tab), toggle headers, enable pretty print or type coercion
- Convert — click Convert to JSON. Conversion is instant, even for large files.
- Copy or download — copy the JSON to clipboard with one click, or download as a
.jsonfile
No sign-up required. Your CSV data never leaves your browser.
Converting CSV to JSON in Code
If you want to automate the process or handle it in your own application:
In JavaScript (Node.js):
function csvToJson(csvText) {
const lines = csvText.trim().split('\n');
const headers = lines[0].split(',').map(h => h.trim());
return lines.slice(1).map(line => {
const values = line.split(',');
return headers.reduce((obj, header, index) => {
obj[header] = values[index]?.trim() ?? '';
return obj;
}, {});
});
}
In Python:
import csv, json
with open('data.csv', 'r') as f:
data = list(csv.DictReader(f))
with open('data.json', 'w') as f:
json.dump(data, f, indent=2)
Command-Line (Node.js):
npx csvtojson data.csv > data.jsonHandling Edge Cases
Quoted fields with commas
If a CSV field contains a comma (e.g., an address like "123 Main St, Apt 4"), it must be wrapped in quotes. FileNaut's converter handles RFC 4180 compliant CSV including quoted fields and multi-line values.
Missing / empty fields
Empty fields become empty strings "" in JSON output. You can optionally filter these out in your application.
Non-UTF-8 files
Files exported from older Windows software sometimes use Windows-1252 encoding. If you see garbled characters, re-save the CSV as UTF-8 in Excel or Google Sheets before converting.
CSV vs JSON — When to Use Each
| Feature | CSV | JSON |
|---|---|---|
| Spreadsheet compatible | ✅ Native | ❌ Needs plugin |
| API compatible | ❌ Rare | ✅ Universal |
| Nested data | ❌ No | ✅ Yes |
| Type support | ❌ Strings only | ✅ String, number, bool, null |