Bỏ qua đến nội dung chính
FreeOnlineTools Go
Tiếng Việt
explanation

CSV Là Gì? Giải thích Đầy đủ về Comma-Separated Values

By FreeOnlineTools Team · Updated 2026-09-02

Quick Answer

CSV là định dạng văn bản cho dữ liệu bảng trong đó mỗi hàng là một dòng và giá trị phân tách bởi dấu phẩy. Hàng đầu thường chứa header cột. CSV dùng cho export, import và trao đổi dữ liệu. Dùng CSV to JSON Converter miễn phí để chuyển CSV sang JSON.

Introduction

CSV (Comma-Separated Values) là định dạng plain-text cho dữ liệu bảng —dữ liệu tổ chức trong hàng và cột, như bảng tính. Mỗi hàng là một dòng văn bản và mỗi giá trị trong hàng phân tách bởi dấu phẩy. CSV là định dạng bảng đơn giản và được hỗ trợ nhiều nhất: mọi bảng tính, cơ sở dữ liệu và công cụ phân tích dữ liệu có thể đọc và viết CSV. Được định nghĩa bởi RFC 4180.

Step by Step

  1. Understand CSV structure

    A CSV file has one row per line, with values separated by commas. The first row is often a header row containing column names. Each subsequent row is a data record. Example: 'name,age,city\nAlice,30,NYC\nBob,25,LA'.

  2. Learn the quoting rules

    Values containing commas, quotes, or newlines must be wrapped in double quotes. A quote inside a quoted value is escaped by doubling it. Example: 'Alice,"Hello, world"' — the comma inside the quotes is part of the value, not a separator.

  3. Recognize CSV variations

    While commas are the standard delimiter, some files use semicolons (;), tabs (TSV), or pipes (|). European locales often use semicolons because commas are used as decimal separators. Always check the delimiter when parsing.

  4. Convert CSV to other formats

    CSV has no type information — all values are strings. When converting to JSON or loading into a program, you may need to convert numeric strings to numbers. Use our CSV to JSON Converter for instant conversion.

Examples

Simple CSV with headers

Input: Three columns, two data rows

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

CSV with quoted values

Input: Value containing a comma

Output: name,note Alice,"Hello, world"

TSV (tab-separated)

Input: Same data, tab delimiter

Output: name age city Alice 30 NYC

Common Problems

  • All values are strings —CSV has no type information. Numbers, dates, and booleans are all stored as text and must be parsed by the application.
  • Inconsistent delimiters —some files use commas, others semicolons or tabs. Detect the delimiter automatically or let the user specify it.
  • Encoding issues —CSV files from Excel may use BOM or Windows-1252 encoding instead of UTF-8. This causes problems with non-ASCII characters.
  • Inconsistent row lengths —some rows may have fewer or more columns than the header. Handle missing values as null and extra values by truncating or erroring.

Tips

  • CSV is best for tabular data —use JSON for nested or hierarchical data.
  • Always quote values containing commas, quotes, or newlines to avoid parsing errors.
  • Use UTF-8 encoding without BOM for maximum compatibility.
  • Use our CSV to JSON Converter to transform CSV into JSON for use in web applications.

Related Tools

Related Guides

References