ข้ามไปยังเนื้อหาหลัก
FreeOnlineTools Go
ไทย
how-to

วิธีแปลง CSV เป็น JSON ทีละขั้นตอน

By FreeOnlineTools Team · Updated 2026-09-02

Quick Answer

วิธีแปลง CSV เป็น JSON: วางข้อมูล CSV ใน CSV to JSON Converter, เลือกว่าแถวแรกเป็น header หรือไม่ แล้วคลิก Convert เครื่องมือ parse CSV และ output JSON array การประมวลผลเกิดในเครื่อง

Introduction

CSV (Comma-Separated Values) เป็นรูปแบบข้อมูลตารางทั่วไป —สเปรดชีต export ฐานข้อมูล และ dataset data science มักใช้ CSV JSON (JavaScript Object Notation) เป็นรูปแบบมาตรฐานสำหรับ web API และแอปสมัยใหม่ การแปลง CSV เป็น JSON ทำให้โหลดข้อมูลตารางเข้า JavaScript หรือส่งไป 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