JSON to CSV Converter
JSONオブジェクト配列をCSVに変換。ネスト平坦化・区切り文字選択・BOM付きUTF-8ダウンロードでExcel連携も安心。
How to Use the JSON to CSV Converter
Paste an array of JSON objects into the input field and click JSON → CSV. The tool reads the keys of every object, builds a unified header row, and outputs RFC 4180-compliant CSV that opens cleanly in Excel, Google Sheets, and BI tools. A simple reverse conversion (CSV → JSON) is also included for round-trip checks.
Features
- Choose the delimiter: comma, tab (TSV), or semicolon for European Excel locales
- Flatten nested objects into dot-notation columns such as
user.name - RFC 4180 escaping: quotes are doubled, and values containing delimiters or line breaks are quoted
- Optional "quote all fields" mode for strict downstream parsers
- Download as UTF-8 with BOM so Japanese text does not break in Excel
- Runs 100% in your browser — no JSON data is uploaded anywhere
What is the difference between JSON and CSV?
JSON is a hierarchical format used by APIs and configuration files; CSV is a flat, tabular format understood by spreadsheets and databases. Converting JSON to CSV means mapping each object to a row and each key to a column. Nested structures do not fit a flat table directly, which is why this tool offers dot-notation flattening: the object{"user":{"name":"Sato"}} becomes a single user.name column instead of an unreadable [object Object] cell.
JSON to CSV Converterの使い方
APIレスポンスやデータベースのエクスポートで得たJSONオブジェクト配列を、ExcelやGoogleスプレッドシートで開けるCSVに変換します。 全行のキーを走査して列を決めるため、行ごとにキーが異なるJSONでも欠損セルは空欄として揃います。 逆方向(CSV → JSON)も簡易対応していますが、型推論や詳細オプションが必要な場合はCSV to JSON Converterをご利用ください。
1. APIレスポンスをExcelで非エンジニアに共有
管理画面APIが返すユーザー一覧JSONをそのまま貼り付けて変換し、「BOM付きでダウンロード」をオンにしてCSVを保存すれば、 Windows版Excelでダブルクリックしても日本語が文字化けしません。営業・CSチームへのデータ共有が数十秒で終わります。
2. ネストしたJSONをdot記法で平坦化
{"user":{"name":"佐藤","address":{"city":"東京"}}} のような階層構造は、 「ネストを平坦化」をオンにすると user.name / user.address.city という列に展開されます。 MongoDBやFirestoreのエクスポートを表形式にする際に有効です。配列フィールドはJSON文字列のままセルに残るので、後段で必要に応じて分解できます。
3. BIツール・データベースへのインポート
Looker StudioやRedashなどのBIツール、PostgreSQLのCOPYコマンドはCSV入力を前提とすることが多く、 JSONログを一度CSVへ落とす場面は頻繁にあります。値にカンマや改行を含むデータ(住所・自由記述など)もRFC 4180準拠で正しく引用されるため、 列ずれを起こさずにインポートできます。区切り文字をタブにすればTSVとしても出力可能です。
よくあるエラーと対処 / Common Errors and Fixes
| エラー / Error | 原因 / Cause | 対処 / Fix |
|---|---|---|
Unexpected token ... in JSON | 入力がJSONとして不正(末尾カンマ・シングルクォートなど) Input is not valid JSON (trailing comma, single quotes) | 先にJSON Formatterで構文を検証する Validate the syntax with the JSON Formatter first |
| 「オブジェクトの配列を入力してください」 | ルートが数値・文字列、または{"data":[...]}のようにラップされているRoot is a scalar, or the array is wrapped under a key like data | dataキー配下の配列部分だけを貼り付けるPaste only the array under the data key |
| Excelで日本語が文字化けする | BOMなしUTF-8をExcelがShift_JISと解釈 Excel reads BOM-less UTF-8 as Shift_JIS | 「BOM付きでダウンロード」をオンにする Enable the UTF-8 BOM download option |
セルに[object Object]と表示される | 他ツールでネストオブジェクトを未処理のまま文字列化 Nested objects stringified naively by another tool | 本ツールの「ネストを平坦化」でuser.name列に展開Use the flatten option to expand into dot-notation columns |
| 取り込み先で列がずれる | 値内のカンマ・改行が引用されていないCSVを使用 Values containing commas or newlines were not quoted | 本ツールはRFC 4180準拠で自動引用。厳格なパーサーには「全フィールドを引用」を併用 This tool quotes automatically per RFC 4180; enable quote-all for strict parsers |
| 行によって空欄のセルができる | 行ごとにキー構成が異なるJSON(欠損フィールド) Objects in the array have different key sets | 仕様どおりの動作。全行のキーの和集合が列になり、欠損は空欄になる Expected behavior: columns are the union of all keys; missing values stay empty |
| Excelで先頭ゼロや長い数値が壊れる (0123→123) | Excelがセルを数値として自動解釈 Excel auto-converts cells to numbers | Excelの「データ」→「テキストファイル」インポートで列の型を文字列に指定 Import via Excel's text import wizard and set the column type to Text |
言語別コード例 / Code Examples by Language
JSON → CSV 変換をコードで再現する最小サンプル。いずれもRFC 4180のエスケープを考慮しています。
Minimal snippets to convert JSON to CSV programmatically, with RFC 4180 escaping in mind.
JavaScript / TypeScript
const rows = JSON.parse(jsonText); // [{...}, {...}]
const headers = [...new Set(rows.flatMap(Object.keys))];
const esc = (v) => {
const s = v == null ? "" : String(v);
return /[",\n\r]/.test(s) ? '"' + s.replace(/"/g, '""') + '"' : s;
};
const csv = [headers.join(","),
...rows.map((r) => headers.map((h) => esc(r[h])).join(","))
].join("\r\n");Python
import csv, json
rows = json.loads(json_text)
headers = list(dict.fromkeys(k for r in rows for k in r))
# encoding="utf-8-sig" で BOM 付き → Excel で文字化けしない
with open("data.csv", "w", newline="", encoding="utf-8-sig") as f:
writer = csv.DictWriter(f, fieldnames=headers)
writer.writeheader()
writer.writerows(rows)Go
import (
"encoding/csv"
"encoding/json"
"os"
)
var rows []map[string]string
json.Unmarshal(data, &rows)
w := csv.NewWriter(os.Stdout) // encoding/csv が RFC 4180 の引用を処理
w.Write([]string{"id", "name"})
for _, r := range rows {
w.Write([]string{r["id"], r["name"]})
}
w.Flush()Shell (jq)
# ヘッダー行 + @csv フィルタで各行をエスケープ付き出力
jq -r '(.[0] | keys_unsorted) as $h
| $h, (.[] | [.[$h[]]])
| @csv' input.json > output.csvBefore / After 実例 / Before & After
例1: オブジェクト配列をCSVへ / Object array to CSV
[
{ "id": 1, "name": "佐藤", "age": 28 },
{ "id": 2, "name": "鈴木", "age": 34 }
]↓
id,name,age
1,佐藤,28
2,鈴木,34例2: ネストをdot記法で平坦化 / Flatten nested objects
[
{ "id": 1, "user": { "name": "佐藤", "address": { "city": "東京" } } }
]↓ (ネストを平坦化: ON)
id,user.name,user.address.city
1,佐藤,東京例3: カンマ・引用符を含む値のエスケープ / Escaping commas and quotes
[
{ "id": 1, "note": "高い, でも\"良い\"製品" }
]↓ (RFC 4180: 値を引用し、内部の " は "" に)
id,note
1,"高い, でも""良い""製品"Why browser-only? / なぜブラウザ完結か
The JSON you convert to CSV is often the most sensitive data you handle: user lists with email addresses, sales records, or production database exports. Uploading that to a server-side converter means a third party receives a full copy, even if the page promises to delete it. DevToolBox performs the entire conversion — parsing, flattening, RFC 4180 escaping, and even the file download via the Blob API — inside your browser with plain JavaScript. No network request carries your data, which you can verify yourself: open DevTools, switch to the Network tab, run a conversion, and watch the tab stay empty. This also means the tool keeps working offline once the page is loaded, and there is no file-size limit imposed by an upload endpoint.
CSVに変換するJSONは、メールアドレス入りのユーザー一覧や売上データなど機密性の高いものがほとんどです。 本ツールは解析・平坦化・エスケープ・ダウンロード(Blob API)まで全てブラウザ内で完結し、ネットワーク送信は一切行いません。 DevToolsのNetworkタブが空のままであることを自分の目で確認できます。
関連ツール / Related Tools
開発をもっと効率的に
PR