How to Convert CSV to JSON
March 22, 2026 · 6 min read
CSV (Comma-Separated Values) is the universal format for tabular data — spreadsheets, database exports, and data dumps almost always come in CSV. But modern APIs, web apps, and config files expect JSON. Converting between them is one of the most common data tasks developers face.
In this guide, you'll learn how to convert CSV to JSON — using an online converter, in code, and from the command line.
CSV vs. JSON: When to Use Which
CSV is best for flat, tabular data — rows and columns, like a spreadsheet. It's compact and universally supported by Excel, Google Sheets, databases, and data tools.
JSON is best for structured, nested data — objects with properties, arrays, and hierarchical relationships. It's the native format for web APIs and JavaScript applications.
The conversion is straightforward: the CSV header row becomes the JSON property names, and each subsequent row becomes an object.
Paste CSV data and get formatted JSON output with one click.
Open CSV to JSON ConverterMethod 1: Online Converter
The fastest approach — paste your CSV into our CSV to JSON converter and get formatted JSON instantly. No installation, no code, works right in your browser.
Method 2: JavaScript
Here's a simple function to parse CSV to JSON in JavaScript:
Caveat: This simple parser doesn't handle quoted fields (values containing commas). For production use, use a library like papaparse:
Method 3: Python
Python's standard library makes this trivial:
For a one-liner from the command line:
Method 4: Command Line
Using jq (if installed)
Using csvjson (csvkit)
Using Node.js
Handling Edge Cases
Real-world CSV data is messy. Here are the common pitfalls:
Quoted Fields with Commas
Fields containing commas or quotes are wrapped in double quotes. Embedded quotes are escaped by doubling them. Simple split(',') won't handle this — use a proper CSV parser.
Type Conversion
CSV is all strings. After converting to JSON, you'll often want to cast types:
Different Delimiters
Not all "CSV" files use commas. TSV (tab-separated), semicolon-separated (common in Europe), and pipe-separated files are all common. Check your delimiter before parsing.
JSON to CSV (The Reverse)
Need to go the other way? Check out our JSON to CSV converter. The key challenge is flattening nested JSON into tabular rows — nested objects need to be serialized or flattened.
Convert Your Data Now
Use the free CSV to JSON converter on UtilShed — paste your data and get clean JSON output instantly.
Related tools for working with data formats:
- JSON to CSV Converter — go the other way
- JSON Formatter — pretty-print and validate JSON
- JSON to YAML Converter — for config file formats
- CSV to XML Converter — for XML-based systems
- JSON Validator — check if your output is valid JSON