CSV to JSON Converter
CSVとJSON形式を即座に相互変換します。引用符・カンマ・特殊文字に対応。
How to Use the CSV to JSON Converter
This free online tool converts between CSV (Comma-Separated Values) and JSON (JavaScript Object Notation) formats. In CSV-to-JSON mode, paste your CSV data with headers in the first row, and the tool generates a JSON array of objects. In JSON-to-CSV mode, paste a JSON array of objects, and the tool produces properly formatted CSV output. Click Convert and copy the result with one click. All processing happens entirely in your browser, so your data remains private and secure.
Understanding CSV and JSON
CSV is a simple, widely-supported tabular data format where each line represents a row and values are separated by commas. It is the standard export format for spreadsheets, databases, and analytics tools. JSON is a hierarchical data format used extensively in web APIs, configuration files, and modern applications. Converting between these formats is a common task when importing data from spreadsheets into web applications, exporting API responses to spreadsheets, or migrating data between systems.
Handling Special Characters
This tool properly handles quoted CSV fields, commas within values, double-quoted characters, and multi-line values. When converting JSON to CSV, values containing commas, quotes, or newlines are automatically wrapped in double quotes following the RFC 4180 standard. This ensures that your converted data maintains its integrity regardless of the content within individual fields.
Tips for Clean Conversions
For CSV-to-JSON conversion, ensure your first row contains column headers that will become the JSON property names. Avoid spaces in header names when possible, as they become object keys. For JSON-to-CSV conversion, provide a flat array of objects where each object has the same keys. Nested objects or arrays in JSON will be converted to their string representation. For best results, flatten complex JSON structures before converting to CSV format.
CSV・JSON相互変換ツールの使い方
CSVとJSON形式をブラウザ上で即座に相互変換できるツールです。引用符やカンマを含むフィールドにもRFC 4180準拠で対応し、変換結果をワンクリックでコピーできます。スプレッドシートとWebアプリ間のデータ変換に便利です。
「CSV → JSON」モードでは、1行目をヘッダ(キー名)として読み取り、2行目以降を1行=1オブジェクトのJSON配列に変換します。「JSON → CSV」モードでは、オブジェクトの配列を貼り付けると、先頭オブジェクトのキーをヘッダ行としたCSVを生成します。変換はすべてお使いのブラウザ内で完結し、貼り付けたデータが外部に送信されることはありません。
実務での活用例
1. スプレッドシートのデータをAPIテスト用のモックJSONにする
ExcelやGoogleスプレッドシートで管理しているテストデータをCSVとしてコピーし、本ツールでJSON配列に変換すれば、そのままモックサーバーのレスポンスやフロントエンドのフィクスチャとして使えます。型はすべて文字列になるため、数値・真偽値が必要なフィールドは変換後に "30" → 30 のように手で直すか、読み込み側でキャストしてください。
2. APIレスポンスをExcelで集計する
APIから取得したJSON配列を「JSON → CSV」で変換し、Excelやスプレッドシートに貼り付ければ、フィルタやピボットテーブルで集計できます。ネストの深いJSONを平坦化してエクスポートしたい場合は、JSON→CSV専用のJSON to CSVが便利です。
3. データベースインポート前の目視チェック
CSVをインポートする前に一度JSONへ変換すると、「どの列のどの値がどのキーに対応するか」が明示的に確認できます。列ズレや空セルは "キー名": "" としてすぐ見つかるため、本番DBへの取り込みミスを事前に防げます。
よくあるエラーと対処 / Common Errors and Fixes
CSV↔JSON変換で実際につまずきやすいポイントをまとめました。特にExcelから書き出したCSVは、BOM・区切り文字・引用符の3点でハマりがちです。
The pitfalls you are most likely to hit when converting between CSV and JSON — especially with CSV files exported from Excel.
| エラー / 症状 / Error or Symptom | 原因 / Cause | 対処 / Fix |
|---|---|---|
CSV must have at least a header row and one data row. | 入力が1行以下。ヘッダ行のみ、または空入力 Input has fewer than two lines — header only, or empty | 1行目にヘッダ、2行目以降にデータの計2行以上を貼り付ける Paste at least a header row plus one data row |
| 全データが1つのキーにまとまる Everything ends up in a single key | セミコロン(;)やタブ区切りのファイル。欧州ロケールのExcelは ; 区切りで出力するThe file is semicolon- or tab-delimited; European Excel locales export with ; | 貼り付け前にエディタの置換でカンマ区切りに統一する Replace the delimiter with commas before pasting |
1列目のキー名が "FEFF名前" のように壊れるFirst key contains an invisible character | Excelが出力するUTF-8 CSVの先頭にBOMが付いている Excel-exported UTF-8 CSV starts with a byte order mark (BOM) | 「UTF-8(BOMなし)」で保存し直すか、先頭1文字を削除 Re-save as UTF-8 without BOM, or delete the first character |
| 引用符を含むセルの途中で列がずれる Columns shift inside a quoted cell | 引用符のエスケープ誤り。RFC 4180は \" ではなく ""(二重化)が正Wrong quote escaping — RFC 4180 doubles quotes ( ""), not backslash | セル内の " は "" に置換してから変換Double every quote inside the cell before converting |
| 1レコードが途中で2行に分断される A record splits into two broken rows | セル内に改行が含まれている。本ツールは行単位で分割するため引用符内改行は非対応 A cell contains a line break; this tool splits on newlines, even inside quotes | セル内改行を除去するかスペースに置換してから貼り付ける Strip or replace embedded line breaks first |
| 1行目のデータがキー名としてJSON化される Row 1 data becomes the JSON keys | ヘッダ行のないCSVを貼った(1行目が実データ) The CSV has no header row — line 1 is real data | 1行目に列名の行を追加してから変換する Add a header line with column names before converting |
JSON must be a non-empty array of objects. | JSON→CSVでトップレベルが配列でない、または空配列 Top level is not an array, or the array is empty | [{...}, {...}] 形式のオブジェクト配列にするWrap your objects in an array |
CSVのセルが [object Object] になるA CSV cell reads [object Object] | JSON内のネストしたオブジェクト・配列が文字列化される Nested objects/arrays are stringified as-is | 事前に平坦化するか、ネスト対応のJSON to CSVを使う Flatten first, or use the dedicated JSON to CSV tool |
言語別コード例 / Code Examples by Language
同じ変換をコードで自動化する場合の最小サンプルです。定期処理や大容量ファイルにはこちらが向きます。
Minimal snippets to automate the same conversion — better suited for recurring jobs and large files.
JavaScript / TypeScript
// CSV → JSON(引用符なしの単純なCSV向け / simple unquoted CSV)
const [head, ...rows] = csvText.trim().split("\n");
const keys = head.split(",");
const json = rows.map((r) =>
Object.fromEntries(r.split(",").map((v, i) => [keys[i], v]))
);
// JSON → CSV
const data = JSON.parse(jsonText);
const headers = Object.keys(data[0]);
const csv = [
headers.join(","),
...data.map((o) => headers.map((h) => o[h]).join(",")),
].join("\n");Python
import csv, io, json, sys
# CSV → JSON(csv.DictReader は引用符・セル内改行も処理)
rows = list(csv.DictReader(io.StringIO(csv_text)))
print(json.dumps(rows, ensure_ascii=False, indent=2))
# JSON → CSV
data = json.loads(json_text)
writer = csv.DictWriter(sys.stdout, fieldnames=data[0].keys())
writer.writeheader()
writer.writerows(data)Go
import (
"encoding/csv"
"encoding/json"
"strings"
)
r := csv.NewReader(strings.NewReader(csvText))
records, _ := r.ReadAll() // RFC 4180準拠で引用符・セル内改行を処理
rows := []map[string]string{}
for _, rec := range records[1:] {
m := map[string]string{}
for i, h := range records[0] {
m[h] = rec[i]
}
rows = append(rows, m)
}
b, _ := json.MarshalIndent(rows, "", " ")Shell (csvkit / jq)
# CSV → JSON (csvkit)
csvjson --indent 2 data.csv
# JSON → CSV (jq)
jq -r '(.[0] | keys_unsorted) as $h | ($h | @csv), (.[] | [.[$h[]]] | @csv)' data.jsonBefore / After 実例 / Before & After
例1: 基本のCSV→JSON / Basic CSV to JSON
名前,年齢,都市
Alice,30,東京
Bob,25,大阪↓
[
{ "名前": "Alice", "年齢": "30", "都市": "東京" },
{ "名前": "Bob", "年齢": "25", "都市": "大阪" }
]数値もすべて文字列("30")になる点に注意。数値型が必要な場合は読み込み側でキャストします。
Note that numbers become strings ("30"); cast them on the consuming side if needed.
例2: カンマ・引用符を含むセル / Cells with commas and quotes
name,quote
Alice,"Hello, ""World"""↓
[
{ "name": "Alice", "quote": "Hello, \"World\"" }
]RFC 4180どおり、引用符内のカンマは区切りとして扱われず、"" は " 1文字に復元されます。
Per RFC 4180, commas inside quotes are not delimiters, and "" unescapes to a single quote.
例3: JSON→CSVの自動クォート / Automatic quoting on JSON to CSV
[
{ "product": "Pen, Blue", "price": 120 },
{ "product": "Notebook", "price": 350 }
]↓
product,price
"Pen, Blue",120
Notebook,350カンマ・引用符・改行を含む値だけが自動で引用符に包まれ、それ以外はそのまま出力されます。
Only values containing commas, quotes, or newlines get wrapped in quotes; everything else stays bare.
Why browser-only? / なぜブラウザ完結か
CSV files are rarely toy data. In real work they are customer lists exported from a CRM, payroll snapshots, sales ledgers, or user tables dumped from a production database — exactly the kind of content that should never leave your machine just to change its format. Many online converters upload your file to a server, transform it there, and return the result; even when the service is honest, your data has crossed the network and may linger in access logs or temporary storage. This converter parses CSV and serializes JSON entirely inside your browser using plain JavaScript (String.split,JSON.parse, JSON.stringify). Nothing is uploaded, and the page keeps working with Wi-Fi switched off. You can verify this yourself: open DevTools, switch to the Network tab, run a conversion, and watch — no request is fired. For personal data covered by GDPR or Japan's APPI, that difference matters.
CSVの中身は顧客リスト・給与データ・売上台帳など、フォーマット変換のためだけに外部へ送ってよいものではない場合がほとんどです。本ツールの変換処理はすべてブラウザ内のJavaScriptで完結し、サーバーへのアップロードは一切発生しません。DevToolsのNetworkタブを開いたまま変換しても通信が発生しないことを、ご自身で確認できます。
関連ツール / Related Tools
開発をもっと効率的に
PR
レンタルサーバー
エックスサーバー
国内シェアNo.1の高速レンタルサーバー(エックスサーバー社調べ)。WordPressも簡単セットアップ。
詳しく見る →レンタルサーバー
ConoHa WING
国内最速クラスのレンタルサーバー。独自ドメイン永久無料特典付き(特典内容は変更される場合があります)。
詳しく見る →レンタルサーバー
mixhost
高速SSD・HTTP/3対応のクラウド型レンタルサーバー。
詳しく見る →VPS
シンVPS
メモリ単価国内最安・オールNVMe SSD搭載の高性能VPS。開発・検証環境の構築に。
詳しく見る →Windows VPS
ConoHa for Windows Server
Windows環境のVPS。リモートデスクトップで開発・検証環境を構築。
詳しく見る →