Hoppa till huvudinnehåll
FreeOnlineTools Go
Svenska
how-to

Konvertera CSV till JSON Steg för Steg

By FreeOnlineTools Team · Updated 2026-09-02

Quick Answer

För att konvertera CSV till JSON: klistra in din CSV-data i CSV to JSON Converter, välj om första raden är en header och klicka på Convert. Verktyget parsar CSV och matar ut en JSON-array av objekt. All bearbetning sker lokalt.

Introduction

CSV (Comma-Separated Values) är ett vanligt format för tabellär data —kalkylblad, databas-export och data science-dataset använder ofta CSV. JSON (JavaScript Object Notation) är standardformatet för webb-API:er och moderna applikationer. Konvertering av CSV till JSON låter dig ladda tabellär data till JavaScript eller skicka till ett API.

Step by Step

  1. Open the CSV to JSON Converter

    Go to the CSV to JSON Converter tool page. The tool accepts any CSV text as input, including values with commas inside quotes.

  2. Paste your CSV data

    Paste your CSV into the input textarea. A typical CSV has one row per line, with values separated by commas. The first row is often a header row containing column names.

  3. Configure header handling

    If your first row contains column names (headers), enable the 'First row is header' option. The tool will use these names as JSON keys. If disabled, each row becomes a JSON array of values.

  4. Set the delimiter (if needed)

    Most CSV files use commas, but some use semicolons, tabs, or pipes. If your file uses a different delimiter, set it in the options. The tool handles quoted values containing the delimiter correctly.

  5. Convert and copy the JSON

    Click Convert. The tool parses the CSV and outputs JSON. With headers, each row becomes an object like {"name":"Alice","age":"30"}. Copy the JSON to your clipboard for use in your application.

Examples

CSV with headers to JSON objects

Input: name,age,city Alice,30,NYC Bob,25,LA

Output: [ {"name":"Alice","age":"30","city":"NYC"}, {"name":"Bob","age":"25","city":"LA"} ]

CSV with quoted values containing commas

Input: name,note Alice,"Hello, world" Bob,"foo, bar"

Output: [ {"name":"Alice","note":"Hello, world"}, {"name":"Bob","note":"foo, bar"} ]

CSV without headers to JSON arrays

Input: Alice,30,NYC Bob,25,LA

Output: [ ["Alice","30","NYC"], ["Bob","25","LA"] ]

Common Problems

  • All CSV values are strings in JSON —numbers like "30" stay as strings. Convert to numbers in your application with Number() or parseInt().
  • Quoted values with embedded commas —a proper CSV parser handles quotes correctly; naive splitting on commas breaks on values like "Hello, world".
  • Inconsistent row lengths —some rows may have fewer or more columns than the header. The tool pads missing values with null or truncates extra values.
  • Encoding issues —CSV files from Excel may use BOM or different encodings. Save as UTF-8 before pasting.

Tips

  • If your CSV has headers, enable the header option to get JSON objects with named keys —much more useful than arrays.
  • Convert numeric strings to numbers in your application after conversion, since CSV has no type information.
  • For large CSV files (10MB+), use a streaming parser instead of loading the entire file into memory.
  • Use our CSV to JSON Converter for instant, private conversion —no data leaves your browser.

Related Tools

Related Guides

References