CSV to JSON Converter

Convert CSV files to JSON instantly — handles headers, custom delimiters, and nested output.

Developer ToolsFreeNo Signup
CSV to JSON Converter
Free Tool

How to use CSV to JSON Converter

**What Are CSV and JSON Formats?** CSV (Comma-Separated Values) and JSON (JavaScript Object Notation) are two of the most widely used data interchange formats in software development, data science, and business intelligence. Understanding both -- and how to convert between them -- is a foundational skill for anyone working with data. **CSV (Comma-Separated Values):** A plain-text tabular format where each line represents one record and fields within each record are separated by commas. The format is defined in RFC 4180 (published 2005 by the IETF). CSV has been used since the earliest days of computing -- IBM Fortran programs in the 1960s used comma-separated data. A CSV file for a contacts list looks like: Name,Email,Age Alice Johnson,alice@example.com,32 Bob Smith,bob@example.com,28 CSV advantages: human-readable, opens in Excel and Google Sheets, extremely compact, supported by every data tool. CSV limitations: no data typing (everything is a string), no support for nested data structures, no standard for encoding or escaping special characters. **JSON (JavaScript Object Notation):** A lightweight data format derived from JavaScript object syntax, standardized as ECMA-404 (2013) and RFC 8259 (2017). JSON supports six data types: strings, numbers, booleans, null, arrays, and objects. Created by Douglas Crockford in the early 2000s as an alternative to XML, JSON became the dominant format for REST APIs within a decade. The same contacts data in JSON: [ {"Name": "Alice Johnson", "Email": "alice@example.com", "Age": 32}, {"Name": "Bob Smith", "Email": "bob@example.com", "Age": 28} ] JSON advantages: supports nested structures, typed data (numbers vs strings), natively parsed by JavaScript, required by most modern REST APIs. JSON limitations: more verbose than CSV, no comments allowed, requires a parser to read programmatically. **How to Use This CSV to JSON Converter** Converting CSV to JSON takes under 10 seconds: 1. Open the CSV to JSON Converter at diztool.com/tools/csv-to-json. 2. Paste your CSV data into the input text area, or click "Upload CSV File" to load a file from your device. 3. Verify the delimiter setting. The tool auto-detects commas, semicolons, tabs, and pipes. Change the delimiter manually if your data uses a non-standard separator. 4. Check the "First row is header" option (enabled by default). When enabled, the first CSV row becomes the JSON object keys. 5. Toggle "Infer data types" to automatically convert numeric strings to JSON numbers and "true"/"false" strings to JSON booleans. Disable this to keep all values as strings. 6. Click Convert. Your JSON output appears instantly in the right panel, formatted with proper indentation. 7. Choose output format: Pretty Print (indented, human-readable) or Minified (compact, smaller file size). 8. Click Copy or Download to save your JSON output. All conversion runs in your browser. Your CSV data is never uploaded to any server. **CSV to JSON Conversion Rules** Understanding how CSV maps to JSON prevents conversion surprises: **Header row as object keys:** The first row of a CSV file becomes the property names of each JSON object. "Name,Email,Age" produces objects with Name, Email, and Age properties. If your CSV has no header row, the converter uses column indices (col_0, col_1, col_2) as property names. **Commas inside values:** A value containing a comma must be wrapped in double quotes in CSV: Alice,"Johnson, Jr.",alice@example.com. Without the quotes, the comma inside "Johnson, Jr." would be misinterpreted as a field delimiter, corrupting the entire row. This is specified in RFC 4180 Section 2. **Escaped quotes:** A double-quote character inside a quoted field must be escaped by doubling it: "She said ""hello""" becomes the string She said "hello" in the parsed output. Forgetting this escaping rule is one of the most common causes of malformed CSV. **Empty cells:** An empty CSV cell (two consecutive commas: Alice,,alice@example.com) typically converts to either null, an empty string "", or is omitted entirely from the JSON object. This tool converts empty cells to null by default, matching common database conventions. **Data type inference:** CSV stores everything as text. "42" is a string in CSV. A smart CSV-to-JSON converter detects that "42" is numeric and outputs 42 (a JSON number) rather than "42" (a JSON string). Similarly, "true" and "false" convert to JSON booleans. You can disable this if you need all values preserved as strings. **Worked Example: Full CSV to JSON Conversion** Input CSV: Product,Price,In Stock,Rating Laptop,999.99,true,4.5 Mouse,29.99,true,4.8 Keyboard,149.99,false,4.2 Output JSON (with type inference enabled): [ { "Product": "Laptop", "Price": 999.99, "In Stock": true, "Rating": 4.5 }, { "Product": "Mouse", "Price": 29.99, "In Stock": true, "Rating": 4.8 }, { "Product": "Keyboard", "Price": 149.99, "In Stock": false, "Rating": 4.2 } ] Notice that Price and Rating are JSON numbers (no quotes), and "In Stock" values are JSON booleans (true/false without quotes). **CSV vs. JSON Comparison** | Feature | CSV | JSON | |---------|-----|------| | Human readability | High (tabular) | Medium (structured) | | File size | Smaller | Larger (property names repeat) | | Data types | None (all strings) | String, number, boolean, null, array, object | | Nested data | Not supported | Fully supported | | Spreadsheet compatibility | Excel, Sheets, LibreOffice | Requires conversion | | REST API compatibility | Rare | Universal standard | | Parser availability | All languages | All languages | | Standard | RFC 4180 | ECMA-404, RFC 8259 | **Real-World Use Cases** **Importing Spreadsheet Data to APIs:** Business teams frequently export data from Google Sheets or Excel as CSV, then need to push that data to a REST API that accepts JSON. The conversion step from CSV to JSON is a daily workflow in operations, finance, and marketing teams at companies of all sizes. **Database Seeding:** Developers building applications often maintain seed data as CSV files (easy to edit in a spreadsheet) and convert to JSON for loading into Firebase, MongoDB, or Supabase. A products CSV becomes a Firestore collection via a simple CSV-to-JSON conversion followed by a batch write. **ETL Pipelines (Extract, Transform, Load):** Data engineers extract data from legacy systems (often CSV format), transform it into JSON for API consumption, and load it into modern data warehouses like Snowflake, BigQuery, or Redshift. CSV-to-JSON conversion is a standard transformation step. **Google Sheets to Firestore:** Google Sheets exports data as CSV (File -> Download -> CSV). Firebase Firestore accepts JSON for batch imports. Converting the Sheet to JSON enables non-technical team members to manage app content through a familiar spreadsheet interface. **Common CSV to JSON Mistakes** **Mistake 1: Inconsistent number of columns** If row 3 has 5 fields but the header only defines 4 columns, the fifth field is orphaned with no key. Strict CSV parsers reject the file; lenient parsers silently drop the extra field. Always ensure every data row has exactly the same number of fields as the header row. **Mistake 2: Wrong delimiter** European countries often use semicolons (;) as the CSV delimiter because commas are used as decimal separators in those locales (1.234,56 instead of 1,234.56). A CSV file from a German Excel user may use semicolons throughout. If your JSON output shows all data concatenated in a single field, check the delimiter setting. **Mistake 3: BOM (Byte Order Mark) characters** Files saved by Excel often include an invisible UTF-8 BOM (bytes EF BB BF at the start of the file). This causes the first column header to appear as "??Name" instead of "Name" in some parsers. If your first JSON property name has strange characters, strip the BOM by resaving the file with a code editor (VS Code, Notepad++) before converting. **Mistake 4: Encoding mismatch** Excel typically saves CSV in the system's default encoding (Windows-1252 on US Windows), while most web tools expect UTF-8. Characters like accented letters (e, a, n), curly quotes, and em dashes appear as garbage characters when an ANSI file is parsed as UTF-8. Always save your CSV as UTF-8 before converting. **Mistake 5: Dates treated as strings** Dates in CSV (2024-01-15, 01/15/2024) are plain strings unless explicitly converted. A CSV-to-JSON converter does not know whether "2024-01-15" is a date, a version number, or a part number -- it outputs it as a string. If your API expects ISO 8601 date objects or Unix timestamps, you need a post-processing step to convert date strings. **Pro Tips** **Handle TSV (Tab-Separated Values) files:** Data exports from databases and scientific software often use tabs instead of commas. Set the delimiter to Tab (or ) in this converter to handle TSV files correctly. **Large files:** For files over 10 MB, browser-based conversion may be slow. In those cases, use Node.js with the csv-parse library or Python's pandas library (pd.read_csv() then df.to_json()) for faster processing. **Nested JSON from flat CSV:** Complex data models require nested JSON that cannot be represented in a flat CSV. For example, a customer with multiple addresses needs a nested structure. You can achieve this post-conversion by writing a small transformation script, or by designing your CSV columns with dot notation (address.street, address.city) that a smart converter can parse into nested objects.

Frequently Asked Questions

How do I convert a CSV file to JSON?

Paste your CSV data into the input field and the converter instantly produces JSON output. The first row of your CSV becomes the JSON object keys (property names), and each subsequent row becomes one JSON object in the output array. For files, click "Upload CSV" to load from your device. The conversion runs entirely in your browser -- no upload to any server.

What delimiter does CSV use -- comma, semicolon, or tab?

Standard CSV uses commas as specified in RFC 4180. However, European locales often use semicolons since commas are used as decimal separators there. Scientific and database exports often use tabs (TSV format). This converter auto-detects the delimiter from your data, or you can manually set it to comma, semicolon, tab, or pipe (|).

How are numbers and booleans handled in CSV to JSON conversion?

CSV stores all values as plain text strings. A smart converter infers data types: "42" becomes the JSON number 42, "3.14" becomes 3.14, "true" and "false" become JSON booleans. This tool performs type inference by default. Disable it to keep all values as JSON strings -- useful when numeric-looking values like ZIP codes (01234) must stay as strings.

What happens if my CSV has commas inside values?

Values containing commas must be wrapped in double quotes in RFC 4180-compliant CSV: Alice,"123 Main St, Apt 4",New York. The quotes tell the parser that the comma is part of the value, not a field separator. This converter fully supports RFC 4180 quoting rules. If your CSV was not properly quoted, values with commas will produce incorrect output.

Can I convert a large CSV file to JSON?

Yes, this converter handles CSV files up to several megabytes in the browser without issues. For files larger than 10 MB, browser performance may vary depending on your device. For very large datasets (100 MB+), consider using Python pandas (pd.read_csv() then df.to_json()) or Node.js with the csv-parse library, which handle gigabyte-scale files efficiently with streaming parsers.

Recommended

Related Tools