-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson-to-csv.html
More file actions
649 lines (588 loc) · 51.4 KB
/
Copy pathjson-to-csv.html
File metadata and controls
649 lines (588 loc) · 51.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JSON to CSV Converter — Excel-Ready Download | FreeDevTool</title>
<meta name="description" content="Free JSON to CSV converter — flatten nested JSON, custom delimiters, RFC 4180 quoting, UTF-8 BOM for Excel. Download as .csv. Browser-only.">
<meta name="robots" content="index, follow">
<meta name="author" content="Anees Ur Rehman">
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","datePublished":"2026-05-02","dateModified":"2026-05-19","inLanguage":"en-US","isPartOf":{"@type":"WebSite","name":"FreeDevTool","url":"https://freedevtool.org"}}</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"Person","name":"Anees Ur Rehman","url":"https://freedevtool.org/about","jobTitle":"Full-stack developer","worksFor":{"@type":"Organization","name":"FreeDevTool","url":"https://freedevtool.org"}}</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "HowTo",
"name": "How to convert JSON to CSV for Excel or Google Sheets",
"description": "Convert JSON arrays to CSV with nested-object flattening, RFC 4180 quoting, and UTF-8 BOM for Excel compatibility.",
"step": [
{"@type":"HowToStep","name":"Paste JSON array","text":"Paste a JSON array of objects (e.g., API response) into the input pane. Conversion happens locally; nothing uploads."},
{"@type":"HowToStep","name":"Flatten nested objects","text":"Nested objects flatten with dot notation: {user:{name:'Alice'}} becomes column 'user.name' with value 'Alice'."},
{"@type":"HowToStep","name":"Configure CSV options","text":"Pick delimiter (comma, semicolon, tab), enable UTF-8 BOM for Excel, choose quoting style (RFC 4180 default)."},
{"@type":"HowToStep","name":"Download or copy","text":"Click Download CSV to save the file, or Copy to clipboard for paste into Google Sheets / Numbers."}
]
}
</script>
<link rel="canonical" href="https://freedevtool.org/json-to-csv">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preload" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=DM+Sans:wght@300;400;500;600&display=swap" as="style">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=DM+Sans:wght@300;400;500;600&display=swap">
<link rel="preload" href="style.css?v=20260502-cards" as="style">
<link rel="stylesheet" href="style.css?v=20260502-cards">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/favicon.svg">
<meta property="og:image" content="https://freedevtool.org/og-image.svg">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="FreeDevTool — 50+ free, fast, privacy-first developer tools">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://freedevtool.org/og-image.svg">
<meta name="twitter:title" content="JSON to CSV Converter — Excel-Ready | FreeDevTool">
<meta name="twitter:description" content="Convert JSON arrays to CSV. Flatten nested objects. UTF-8 BOM for Excel. Runs in browser, no signup.">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-3L0CMH3X36"></script>
<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag('js',new Date());gtag('config','G-3L0CMH3X36');</script>
<meta property="og:title" content="JSON to CSV Converter — Free Online Tool">
<meta property="og:description" content="Convert JSON arrays to CSV. Download for Excel/Google Sheets. Handles nested objects.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://freedevtool.org/json-to-csv">
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebApplication","name":"JSON to CSV Converter","url":"https://freedevtool.org/json-to-csv","description":"Convert JSON data to CSV format. Download for Excel or Google Sheets.","applicationCategory":"DeveloperApplication","operatingSystem":"Any","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"}}</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"FAQPage","mainEntity":[{"@type":"Question","name":"How do I convert a JSON file to CSV?","acceptedAnswer":{"@type":"Answer","text":"Paste your JSON array of objects into this tool and it automatically extracts headers from object keys and converts values to CSV rows. Click Download CSV to save the file. The JSON must be an array of objects like [{\"name\":\"Alice\",\"age\":30},{\"name\":\"Bob\",\"age\":25}]."}},{"@type":"Question","name":"Can I convert nested JSON to CSV?","acceptedAnswer":{"@type":"Answer","text":"Yes. This tool flattens nested objects using dot notation. For example, {\"user\":{\"name\":\"Alice\"}} becomes a column header 'user.name' with value 'Alice'. Nested arrays are serialized as JSON strings in the CSV cell."}},{"@type":"Question","name":"What is the difference between JSON and CSV?","acceptedAnswer":{"@type":"Answer","text":"JSON (JavaScript Object Notation) is a hierarchical data format supporting nested objects and arrays. CSV (Comma-Separated Values) is a flat, tabular format with rows and columns. JSON is better for APIs and complex data structures; CSV is better for spreadsheets and tabular data analysis."}},{"@type":"Question","name":"How do I open JSON data in Excel?","acceptedAnswer":{"@type":"Answer","text":"Convert your JSON to CSV using this tool, then open the CSV file in Excel. Excel natively opens CSV files and places each comma-separated value into its own cell. For large datasets, use Excel's Power Query (Get Data > From JSON) to import JSON directly."}},{"@type":"Question","name":"Is there a size limit for conversion?","acceptedAnswer":{"@type":"Answer","text":"This tool processes everything in your browser, so the limit depends on your device's memory. Typical browsers handle JSON files up to 50-100MB comfortably. For very large files (100MB+), consider using command-line tools like jq or Node.js scripts."}},{"@type":"Question","name":"How do I convert nested JSON to CSV?","acceptedAnswer":{"@type":"Answer","text":"Flatten nested objects using dot notation — user.name as a column. Arrays are harder: either pick one array index per row, expand each element into a new row, or join them with a delimiter. There is no universally correct mapping; pick what your downstream tool expects."}},{"@type":"Question","name":"How do you handle JSON arrays when converting to CSV?","acceptedAnswer":{"@type":"Answer","text":"Three approaches: (1) Pipe-delimit array elements in one cell; (2) Expand each array element into its own row, repeating other fields; (3) Limit to a fixed array size and create numbered columns. Excel-friendly converters usually pick option 1 or 3."}},{"@type":"Question","name":"What is the best delimiter for CSV files?","acceptedAnswer":{"@type":"Answer","text":"Comma is the standard but problematic in many languages (European notation uses comma as decimal separator). Tab (TSV) avoids the issue. Pipe is also common. RFC 4180 specifies comma; Excel and Google Sheets handle TSV and pipe equally well."}}]}</script>
<style>.char-count{font-family:var(--mono);font-size:11px;color:var(--text3);text-align:right;margin-top:4px}.csv-preview{max-height:300px;overflow:auto}.stats-row{display:flex;gap:16px;margin-top:10px;font-family:var(--mono);font-size:12px;color:var(--text3)}</style>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://freedevtool.org/"
},
{
"@type": "ListItem",
"position": 2,
"name": "All Tools",
"item": "https://freedevtool.org/all-tools"
},
{
"@type": "ListItem",
"position": 3,
"name": "JSON to CSV Converter",
"item": "https://freedevtool.org/json-to-csv"
}
]
}
</script>
<script src="/ga4-events.js" defer></script>
</head>
<body>
<nav>
<a class="nav-logo" href="/" aria-label="FreeDevTool home"><svg class="logo-mark" width="22" height="22" viewBox="0 0 24 24" aria-hidden="true" fill="none"><rect x="1" y="1" width="22" height="22" rx="6" fill="currentColor" opacity=".12"/><path d="M9.5 8.5L6 12l3.5 3.5M14.5 8.5L18 12l-3.5 3.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>FreeDevTool</a>
<div class="nav-links">
<div class="nav-dropdown" id="tools-dropdown">
<a href="all-tools" onclick="event.preventDefault();this.parentElement.classList.toggle('open')" aria-haspopup="true">Tools <svg class="chev" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg></a>
<div class="nav-dropdown-menu">
<a href="encoding-tools">
<div class="dd-icon">b64</div>
<div class="dd-info"><div class="dd-name">Encoding & Conversion</div><div class="dd-count">11 tools · Base64, YAML, px→rem</div></div>
</a>
<a href="generation-tools">
<div class="dd-icon">{ }</div>
<div class="dd-info"><div class="dd-name">Generation & Formatting</div><div class="dd-count">16 tools · JSON, SQL, gradients</div></div>
</a>
<a href="security-tools">
<div class="dd-icon">#</div>
<div class="dd-info"><div class="dd-name">Security & Hashing</div><div class="dd-count">3 tools · JWT, MD5, SHA</div></div>
</a>
<a href="text-tools">
<div class="dd-icon">.*</div>
<div class="dd-info"><div class="dd-name">Code & Text Tools</div><div class="dd-count">9 tools · Regex, diff, tokens</div></div>
</a>
<a href="devops-tools">
<div class="dd-icon">JS</div>
<div class="dd-info"><div class="dd-name">Optimization & DevOps</div><div class="dd-count">7 tools · Minifiers, cURL, git</div></div>
</a>
<a href="network-tools">
<div class="dd-icon">IP</div>
<div class="dd-info"><div class="dd-name">Network & Time</div><div class="dd-count">4 tools · IP, DNS, timestamps</div></div>
</a>
<a href="seo-tools">
<div class="dd-icon">SEO</div>
<div class="dd-info"><div class="dd-name">SEO & Meta Tools</div><div class="dd-count">3 tools · OG, meta, slug</div></div>
</a>
<div class="nav-dropdown-divider"></div>
<a class="dd-all" href="all-tools">
<div class="dd-icon">All</div>
<div class="dd-info"><div class="dd-name">Browse all 50 tools</div><div class="dd-count">Searchable catalog & categories</div></div>
</a>
</div>
</div>
<a href="/guides">Guides</a>
<a href="about">About</a>
<a href="privacy">Privacy</a>
</div>
</nav>
<div id="copy-toast">Copied!</div>
<div class="wrapper">
<a class="tool-back" href="/" aria-label="Back to home">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 18l-6-6 6-6"/></svg>
Back
</a>
<div class="tool-header">
<div class="tool-badge">Data Tool</div><h1>JSON to CSV Converter Online — Excel-Ready</h1><p class="tool-description">Convert JSON arrays of objects to CSV format. Auto-extracts column headers from JSON keys, flattens nested objects with <strong>dot notation</strong>, escapes commas/quotes/newlines per <a href="https://datatracker.ietf.org/doc/html/rfc4180" rel="noopener" style="color:var(--accent)">RFC 4180</a>, optionally prepends UTF-8 BOM for Excel compatibility. Custom delimiters (comma, tab, semicolon). Handles large datasets entirely client-side — sensitive customer data never leaves your browser.</p><div class="last-updated">Last updated: May 2026 · Written by <a href="/about">Anees Ur Rehman</a>, full-stack developer</div></div>
<div class="tool-card">
<div class="tool-card-header"><div class="dot dot-red"></div><div class="dot dot-yellow"></div><div class="dot dot-green"></div><span class="tool-card-title">json-to-csv.tool</span></div>
<div class="tool-body">
<label>Paste JSON (Array of Objects)</label>
<textarea id="json-input" placeholder='[
{"name": "Alice", "age": 30, "city": "New York"},
{"name": "Bob", "age": 25, "city": "London"},
{"name": "Charlie", "age": 35, "city": "Tokyo"}
]' oninput="convert()" rows="8"></textarea>
<div class="char-count" id="input-count">0 characters</div>
<div style="display:flex;gap:8px;align-items:center;margin-top:8px;flex-wrap:wrap">
<label style="margin:0;font-size:12px;text-transform:none;letter-spacing:normal">Delimiter:</label>
<select id="delimiter" onchange="convert()" style="padding:6px 10px"><option value=",">, (Comma)</option><option value=";">; (Semicolon)</option><option value="	">Tab</option></select>
<label style="margin:0;display:flex;align-items:center;gap:4px;font-size:12px;text-transform:none;letter-spacing:normal;cursor:pointer"><input type="checkbox" id="flatten" checked onchange="convert()"> Flatten nested objects</label>
</div>
<div id="json-error" style="display:none"></div>
<div class="divider"></div>
<div class="output-label"><label style="margin:0">CSV Output</label><div style="display:flex;gap:6px"><button class="btn btn-ghost" onclick="copyOutput()">Copy</button><button class="btn btn-primary" id="download-btn" onclick="downloadCSV()" style="display:none">Download CSV</button></div></div>
<div class="output-block csv-preview" id="csv-output" style="color:var(--text2);font-style:italic">Paste JSON above to convert...</div>
<div class="stats-row" id="stats" style="display:none"></div>
</div>
</div>
<!-- =============================================================
LONG-FORM ARTICLE — comprehensive guide for E-E-A-T + ranking.
============================================================= -->
<article>
<p class="aeo-lead" style="font-size:16px;line-height:1.7;color:var(--text);max-width:760px;margin:24px auto 18px;padding:0 4px">
<strong>JSON to CSV conversion</strong> flattens JSON arrays of objects into comma-separated rows. Nested keys can be expanded with dot notation, arrays handled per-row or with delimiters, and the output is RFC 4180 compliant for Excel and database imports. This <strong>free JSON to CSV converter</strong> handles nested objects, custom delimiters, quoted commas, embedded newlines, and UTF-8 BOM for Excel compatibility — all in your browser.
</p>
<section id="examples" style="max-width:760px;margin:24px auto 32px">
<h2 style="font-size:18px;margin-bottom:14px">Examples</h2>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">Flat array of objects§§Input JSON:§§[{"name":"Alice","age":30},{"name":"Bob","age":25}]§§Output CSV:§§name,age§§Alice,30§§Bob,25</strong>
</div>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">Nested object with dot notation§§Input:§§[{"user":{"name":"Alice","city":"NYC"}}]§§Output (flattened):§§user.name,user.city§§Alice,NYC</strong>
</div>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">Quoted commas§§Input:§§[{"text":"Hello, World"}]§§Output:§§text§§"Hello, World"§§RFC 4180 requires quoting any field containing a comma or quote. The quote inside is doubled.</strong>
</div>
</section>
<aside class="founder-note" style="max-width:760px;margin:24px auto 32px;padding:20px 24px;background:rgba(0,208,132,0.05);border-left:3px solid var(--accent);border-radius:6px;font-size:14px;line-height:1.7;color:var(--text2)"><div style="font-family:var(--mono);font-size:11px;color:var(--accent);letter-spacing:1.5px;text-transform:uppercase;margin-bottom:10px;font-weight:600">💡 Why I built this</div><p style="margin:0 0 12px">I built this after exporting customer data from a SaaS dashboard, opening the CSV in Excel, and watching it mangle every comma inside a quoted field. The free converters online were not handling RFC 4180 escaping properly. This converter handles nested JSON (with dot-notation flattening), arrays of arrays, quoted commas, embedded newlines — all correctly, all in browser. Excel-compatible by default.</p><p style="margin:0;font-size:13px;color:var(--text3)">— <a href="/about" style="color:var(--accent);text-decoration:none">Anees Ur Rehman</a>, full-stack developer</p></aside>
<section class="article-section">
<h2>What is CSV and why convert JSON to it?</h2>
<p><strong>CSV (Comma-Separated Values)</strong> is the lingua franca of tabular data. Defined informally for decades and standardized in <a href="https://datatracker.ietf.org/doc/html/rfc4180" rel="noopener">RFC 4180</a> (2005), CSV is a flat-text format where each line is a row and each row contains comma-separated values. It opens natively in Excel, Google Sheets, Numbers, every analytics tool, and every database import wizard. Its simplicity is its superpower — you can read a CSV in any text editor.</p>
<p>JSON is hierarchical (nested objects, arrays, mixed types); CSV is flat (rows × columns of strings). Converting between them is one of the most common data tasks in 2026:</p>
<ul>
<li><strong>API responses → spreadsheets</strong> — fetch from a JSON API, hand a CSV to your finance team.</li>
<li><strong>Database exports → analysis</strong> — most databases export to JSON; analysts want CSV.</li>
<li><strong>Bulk imports</strong> — migrating 10,000 records into a new system that only accepts CSV uploads.</li>
<li><strong>Reporting</strong> — JSON event logs → CSV for stakeholders to filter in Excel.</li>
<li><strong>Data science prep</strong> — Pandas, R, and BigQuery all happily ingest CSV; nested JSON requires preprocessing.</li>
</ul>
<p>The conversion is conceptually simple — extract the keys, write headers, write each object as a row — but the devil is in the details: nested objects, mixed schemas, commas inside values, Unicode, and Excel's many CSV quirks.</p>
</section>
<section class="article-section">
<h2>The CSV format — RFC 4180 in plain English</h2>
<p>The "informal" CSV spec is full of dialects, but RFC 4180 codifies the most-compatible rules. Follow these and your CSV will work in 99% of consumers:</p>
<ul>
<li><strong>Each record on its own line</strong>, terminated by CRLF (<code>\r\n</code>). Lone <code>\n</code> works in most modern parsers but RFC says CRLF.</li>
<li><strong>Fields separated by commas</strong>. (Some "CSV" files actually use semicolons, tabs, or pipes — those are TSV/SSV, not strict CSV.)</li>
<li><strong>Optional header line</strong> as the first record.</li>
<li><strong>Fields containing commas, double-quotes, or line breaks must be quoted</strong> with double quotes. <code>Smith, John</code> → <code>"Smith, John"</code>.</li>
<li><strong>Double-quotes inside quoted fields must be escaped by doubling them.</strong> <code>She said "hi"</code> → <code>"She said ""hi"""</code>.</li>
<li><strong>No trailing comma</strong> at end of row (some parsers tolerate it; many don't).</li>
<li><strong>UTF-8 is the modern encoding.</strong> But Microsoft Excel on Windows defaults to system encoding (Windows-1252) unless you prepend a UTF-8 BOM.</li>
</ul>
</section>
<section class="article-section">
<h2>Flattening nested JSON — three approaches</h2>
<p>The hard problem in JSON→CSV is what to do with nested objects and arrays. CSV is flat; JSON isn't. Three common strategies:</p>
<h3>1. Dot-notation flattening (default for this tool)</h3>
<p>Walk the JSON tree, joining keys with dots. <code>{user: {name: "Alice", address: {city: "NYC"}}}</code> becomes columns <code>user.name</code> and <code>user.address.city</code>. Works for moderately nested data; column names get unwieldy past 3 levels deep.</p>
<h3>2. Stringify-arrays</h3>
<p>For arrays, serialize the entire array as a JSON string in a single cell: <code>{tags: ["a","b","c"]}</code> → <code>tags</code> column with value <code>["a","b","c"]</code>. Loses tabular nature but preserves data.</p>
<h3>3. Cartesian-product expansion (one-to-many)</h3>
<p>For arrays of objects, emit one row per array item. <code>{user: "Alice", orders: [{id: 1}, {id: 2}]}</code> becomes 2 rows, both with <code>user=Alice</code>, but different <code>orders.id</code> values. Useful for joining order line items to orders.</p>
<table class="ref-table">
<thead><tr><th>Strategy</th><th>Best for</th><th>Trade-off</th></tr></thead>
<tbody>
<tr><td>Dot notation</td><td>Nested objects (configs, profile fields)</td><td>Long column names; lossy on arrays</td></tr>
<tr><td>Stringify arrays</td><td>Mixed nested data, machine-only consumers</td><td>Cell contains JSON, not human-readable</td></tr>
<tr><td>Cartesian expansion</td><td>One-to-many relationships (orders → line items)</td><td>Repeats parent data on every row</td></tr>
</tbody>
</table>
</section>
<section class="article-section">
<h2>The Excel CSV gotchas — what trips everyone up</h2>
<h3>1. UTF-8 without BOM = corrupted accents</h3>
<p>Open a UTF-8 CSV in Microsoft Excel on Windows: accented characters like <code>é</code> show up as <code>é</code>. The fix is a 3-byte BOM (<code>0xEF 0xBB 0xBF</code>) at the start of the file. Mac Excel and Google Sheets handle UTF-8 natively; Windows Excel needs the BOM. <strong>Most online JSON-to-CSV tools forget this.</strong> This one prepends the BOM by default.</p>
<h3>2. Date columns lose precision</h3>
<p>Dates that look like <code>2026-05-02</code> get auto-converted by Excel to its native serial number. Dates with leading zeros (<code>"01-02-2026"</code>) might be reformatted as <code>"1/2/2026"</code>. <strong>Workaround:</strong> prepend dates with a tab character (<code>\t2026-05-02</code>) or wrap in <code>="2026-05-02"</code> formula syntax to force string interpretation.</p>
<h3>3. Number formatting</h3>
<p>Long numbers like phone numbers or credit card numbers get scientific-notation'd in Excel. <code>4117234567890</code> → <code>4.11723E+12</code>. Same workaround: <code>="4117234567890"</code> in the cell forces string.</p>
<h3>4. Locale-specific delimiter conflicts</h3>
<p>European Excel installs default to <strong>semicolon</strong> as the CSV delimiter (because comma is the decimal separator in those locales). A US-format CSV with commas will appear as a single mangled column. <strong>Workaround:</strong> use the SEP indicator: prepend the file with <code>sep=,\n</code> on the first line, and Excel will respect it regardless of locale.</p>
<h3>5. Leading equals sign</h3>
<p>Excel treats values starting with <code>=</code>, <code>+</code>, <code>-</code>, <code>@</code> as formulas — including dangerous ones. A CSV cell containing <code>=cmd|'/c calc'!A1</code> can launch the Calculator app on Windows when the user opens the file. This is <strong>CSV injection</strong>, a real attack vector. <strong>Workaround:</strong> prefix any string starting with these chars with a single tick: <code>'=username</code>.</p>
</section>
<section class="article-section">
<h2>JSON to CSV in 8 programming languages</h2>
<h3>JavaScript / Node.js</h3>
<div class="lang-block">
<div class="lang-block-header">javascript</div>
<pre><code>// Vanilla JS for simple cases
function jsonToCsv(arr) {
const headers = [...new Set(arr.flatMap(o => Object.keys(o)))];
const rows = arr.map(o =>
headers.map(h => JSON.stringify(o[h] ?? '')).join(',')
);
return [headers.join(','), ...rows].join('\n');
}
// Or use a library: csv-stringify, papaparse, json-2-csv
import { stringify } from 'csv-stringify/sync';
const csv = stringify(arr, { header: true });
</code></pre>
</div>
<h3>Python</h3>
<div class="lang-block">
<div class="lang-block-header">python</div>
<pre><code>import csv, json
with open('data.json') as f:
data = json.load(f)
# Auto-detect headers from first object
fieldnames = list(data[0].keys()) if data else []
with open('out.csv', 'w', newline='', encoding='utf-8-sig') as f: # 'utf-8-sig' adds BOM
writer = csv.DictWriter(f, fieldnames=fieldnames)
writer.writeheader()
writer.writerows(data)
# Pandas approach for nested data
import pandas as pd
df = pd.json_normalize(data) # auto-flattens dot notation
df.to_csv('out.csv', index=False, encoding='utf-8-sig')
</code></pre>
</div>
<h3>jq (command-line JSON processor)</h3>
<div class="lang-block">
<div class="lang-block-header">jq</div>
<pre><code># Convert array of objects to CSV
jq -r '(.[0] | keys_unsorted) as $keys | $keys, map([.[ $keys[] ]])[] | @csv' data.json
# Custom column selection
jq -r '.[] | [.name, .age, .email] | @csv' data.json
# With headers
echo '"name","age","email"'; jq -r '.[] | [.name,.age,.email] | @csv' data.json
</code></pre>
</div>
<h3>Go</h3>
<div class="lang-block">
<div class="lang-block-header">go</div>
<pre><code>import (
"encoding/csv"
"encoding/json"
"os"
)
var data []map[string]interface{}
json.Unmarshal(jsonBytes, &data)
f, _ := os.Create("out.csv")
defer f.Close()
f.WriteString("\xEF\xBB\xBF") // UTF-8 BOM for Excel
w := csv.NewWriter(f)
defer w.Flush()
// Write headers
headers := []string{"name", "age", "email"}
w.Write(headers)
// Write rows
for _, item := range data {
row := []string{
fmt.Sprint(item["name"]),
fmt.Sprint(item["age"]),
fmt.Sprint(item["email"]),
}
w.Write(row)
}
</code></pre>
</div>
<h3>PHP</h3>
<div class="lang-block">
<div class="lang-block-header">php</div>
<pre><code>$data = json_decode(file_get_contents('data.json'), true);
$fp = fopen('out.csv', 'w');
fwrite($fp, "\xEF\xBB\xBF"); // UTF-8 BOM
// Headers
fputcsv($fp, array_keys($data[0]));
// Rows
foreach ($data as $row) {
fputcsv($fp, $row);
}
fclose($fp);
</code></pre>
</div>
<h3>Ruby</h3>
<div class="lang-block">
<div class="lang-block-header">ruby</div>
<pre><code>require 'json'
require 'csv'
data = JSON.parse(File.read('data.json'))
CSV.open('out.csv', 'w', write_headers: true,
headers: data.first.keys, encoding: 'bom|utf-8') do |csv|
data.each { |row| csv << row.values }
end
</code></pre>
</div>
<h3>Bash / awk</h3>
<div class="lang-block">
<div class="lang-block-header">bash</div>
<pre><code># With jq + miller (if installed)
jq -r 'map([.name, .age, .email] | @csv)[]' data.json > out.csv
# Excel-friendly: prepend BOM
printf '\xEF\xBB\xBF' > out.csv
jq -r '(map(keys_unsorted) | add | unique) as $k |
($k | @csv), (.[] | [.[$k[]]] | @csv)' data.json >> out.csv
</code></pre>
</div>
<h3>Excel / Power Query (no code)</h3>
<div class="lang-block">
<div class="lang-block-header">excel</div>
<pre><code># Excel 365 / 2019+:
# Data tab → Get Data → From File → From JSON
# → Select your .json file
# → Power Query opens with auto-flattened columns
# → Click "Close & Load" — JSON is now a sheet
# This handles nested objects via Power Query's transformations,
# without manually flattening</code></pre>
</div>
</section>
<section class="article-section">
<h2>Common JSON-to-CSV mistakes</h2>
<ul>
<li><strong>Forgetting the BOM for Excel.</strong> The #1 reported issue. Always prepend <code>\xEF\xBB\xBF</code> for Windows Excel users.</li>
<li><strong>Not escaping commas/quotes inside cells.</strong> A field <code>Hello, world</code> without quoting splits into 2 cells. Always use a real CSV writer, not string concatenation.</li>
<li><strong>Mixed schema across array.</strong> Object 1 has <code>{a, b}</code>, object 2 has <code>{a, c}</code>. Naive flattening uses object 1's keys and drops <code>c</code>. Compute headers as the union of all keys.</li>
<li><strong>Date / number coercion in Excel.</strong> Phone numbers as scientific notation. Dates reformatted. Pre-quote with <code>=</code>-syntax or tab prefix.</li>
<li><strong>Treating <code>null</code> and <code>""</code> the same.</strong> CSV has no null. Pick a convention: empty cell, <code>NULL</code> string, or distinguish via separate flag column.</li>
<li><strong>Nested arrays serialized inconsistently.</strong> Sometimes <code>JSON.stringify</code>, sometimes <code>;</code>-separated. Pick one.</li>
<li><strong>CSV injection.</strong> A user-supplied field starting with <code>=</code> can execute formulas in Excel. Prefix with <code>'</code> for safety.</li>
<li><strong>Wrong line endings.</strong> Mixed <code>\n</code> and <code>\r\n</code> across rows. Use the platform's CSV writer to pick consistently.</li>
<li><strong>Forgotten encoding.</strong> Windows-1252 vs UTF-8 vs ISO-8859-1. Always use UTF-8 with BOM for cross-platform compatibility.</li>
</ul>
</section>
<section class="article-section">
<h2>Best practices</h2>
<ul>
<li><strong>Always emit UTF-8 with BOM</strong> when the file might open in Excel.</li>
<li><strong>Use a real CSV library</strong>, not string concatenation. The escaping rules are subtle.</li>
<li><strong>Compute headers from the union of all keys</strong>, not just the first object's keys. Mixed schemas are common in real data.</li>
<li><strong>Document your nested-data strategy.</strong> Dot notation? Stringify arrays? Cartesian expansion? Pick one and document so consumers know what to expect.</li>
<li><strong>Quote dates and IDs.</strong> Excel auto-converts otherwise. Wrap in <code>="..."</code> formula syntax for hard preservation.</li>
<li><strong>Sanitize formula triggers.</strong> Prefix any string starting with <code>=</code>, <code>+</code>, <code>-</code>, <code>@</code> with a tick to prevent CSV injection.</li>
<li><strong>For huge datasets, stream don't accumulate.</strong> Build CSV row-by-row to avoid loading everything into memory.</li>
<li><strong>Test the round-trip.</strong> Convert JSON → CSV → JSON and verify equivalence. Catches escaping and encoding bugs early.</li>
<li><strong>Consider Parquet or NDJSON for large datasets.</strong> CSV's flat schema and lack of types make it a poor archive format. CSV for human consumption; binary formats for machines.</li>
</ul>
</section>
</article>
<!-- How to use + mistakes -->
<section class="use-cases">
<h2>How to use the JSON to CSV converter</h2>
<p>Convert JSON arrays of objects into CSV files for spreadsheets (Excel, Google Sheets, Numbers), data import, and analytics. The converter flattens nested objects with dot-notation, handles arrays, and quotes values containing commas or newlines correctly per RFC 4180.</p>
<ul class="use-case-list">
<li><strong>1.</strong> Paste your JSON. Top level should be an <strong>array of objects</strong> (<code>[{"a": 1}, {"a": 2}]</code>). A single object converts to a 1-row CSV.</li>
<li><strong>2.</strong> Headers auto-detect from the union of all object keys. Toggle "alphabetize" or drag to reorder.</li>
<li><strong>3.</strong> Pick a delimiter: comma (default — Excel/Sheets standard), tab (TSV — paste-friendly into spreadsheets), or semicolon (Euro-localized Excel).</li>
<li><strong>4.</strong> Choose how to handle nested objects: flatten with dot-notation (<code>address.city</code>) or JSON-stringify the value into a single cell.</li>
<li><strong>5.</strong> Download as <code>.csv</code> or copy to clipboard. UTF-8 BOM is added when "Excel-compatible" is enabled — fixes accented chars in Windows Excel.</li>
</ul>
<h3>Common mistakes to avoid</h3>
<ul class="mistakes-list">
<li><strong>Forgetting the UTF-8 BOM for Excel.</strong> Without it, Windows Excel mangles accented characters (<code>café</code> → <code>café</code>). Toggle "Excel-compatible" or prepend <code>\ufeff</code> manually.</li>
<li><strong>Not quoting values with commas, quotes, or newlines.</strong> Per RFC 4180, those values must be wrapped in <code>"</code>; embedded quotes become <code>""</code>. The converter does this automatically — don't manually edit the output.</li>
<li><strong>Expecting heterogeneous arrays to round-trip.</strong> JSON arrays of mixed types (<code>[1, "a", {}]</code>) lose type info in CSV — everything becomes a string. Validate after import.</li>
<li><strong>Using <code>;</code> delimiter then sharing the file globally.</strong> Localized Excel uses <code>;</code> for German/French; US Excel uses <code>,</code>. Pick based on your audience or use TSV (works everywhere).</li>
<li><strong>Flattening deeply nested data.</strong> Dot-notation works for 1–2 levels; beyond that, headers become unreadable (<code>user.address.geo.coordinates.lat</code>). Pre-process to extract just what you need.</li>
<li><strong>Treating the output as canonical data.</strong> CSV loses types, precision, and structure. Use it for human-facing exports — keep JSON or Parquet as your source of truth.</li>
</ul>
</section>
<section class="article-section">
<h2>Best JSON to CSV converter for 2026 — what to compare</h2>
<p>Search results for "json to csv online", "convert json to excel", and "json csv converter" return many tools but most fail on real-world JSON: they don't handle nested objects (silently dropping data), they break on JSON arrays inside object properties, they don't add a UTF-8 BOM (so Excel mangles accented characters), or they upload your data to a server. Here's how the most-used JSON-to-CSV tools compare in 2026:</p>
<table class="ref-table">
<thead><tr><th>Tool</th><th>Browser-only</th><th>Nested object flatten</th><th>UTF-8 BOM for Excel</th><th>Custom delimiter</th><th>Cost</th></tr></thead>
<tbody>
<tr><td>FreeDevTool JSON to CSV</td><td>Yes</td><td>Dot notation (default)</td><td>Yes (toggle)</td><td>Yes (, ; \t)</td><td>Free</td></tr>
<tr><td>convertcsv.com/json-to-csv.htm</td><td>Server-side</td><td>Limited</td><td>Yes</td><td>Yes</td><td>Free, ad-funded</td></tr>
<tr><td>json-csv.com</td><td>Server-side</td><td>Yes</td><td>Yes</td><td>Limited</td><td>Free + paid Pro</td></tr>
<tr><td>npm <code>json2csv</code></td><td>Local install</td><td>Yes (configurable)</td><td>Yes</td><td>Yes</td><td>Free, OSS</td></tr>
<tr><td>Python <code>pandas.json_normalize</code></td><td>Local Python</td><td>Yes (full)</td><td>N/A (write_csv encoding)</td><td>Yes</td><td>Free, OSS</td></tr>
<tr><td><code>jq</code> CLI + <code>@csv</code> filter</td><td>Local install</td><td>Manual</td><td>Manual</td><td>Yes</td><td>Free, OSS</td></tr>
</tbody>
</table>
<h3>How do I convert nested JSON to CSV without losing data?</h3>
<p>Three flattening strategies handle 99% of nested JSON. <strong>Dot notation (default here)</strong>: <code>{user:{name:"Alice",city:"NYC"}}</code> → columns <code>user.name</code>, <code>user.city</code>. Best when the nesting is a fixed schema. <strong>Stringify arrays</strong>: <code>{tags:["red","blue"]}</code> → column <code>tags</code> with value <code>["red","blue"]</code>. Best when arrays are display-only (re-import preserves the JSON). <strong>Cartesian product expansion</strong>: <code>{order:1, items:[{sku:"A"},{sku:"B"}]}</code> → 2 rows with <code>order=1</code> repeated. Best when arrays represent one-to-many relationships and you want spreadsheet-friendly rows. This converter uses dot notation by default; for the other two strategies, use <code>jq</code> or pandas.</p>
<h3>Why does Excel mangle accented characters when I open my CSV?</h3>
<p>Excel on Windows treats CSV as ANSI/Windows-1252 by default unless the file starts with a UTF-8 Byte Order Mark (BOM, bytes <code>EF BB BF</code>). Without BOM: <code>café</code> renders as <code>café</code>. Three fixes: <strong>1)</strong> Enable the "UTF-8 BOM" toggle in this converter (default on) — file opens correctly in Excel for Mac, Excel for Windows, and Numbers; <strong>2)</strong> If you control the export pipeline, write <code></code> as the first character; <strong>3)</strong> If you can't add BOM, open Excel → Data → From Text/CSV → File Origin: 65001 (UTF-8). Modern Excel 2021+ defaults to UTF-8 detection but older Office installations don't. The BOM is the safe path.</p>
<h3>JSON to CSV alternative to convertcsv.com — 4 reasons developers switched</h3>
<ol>
<li><strong>Browser-only, no server upload.</strong> convertcsv.com and json-csv.com POST your data to a server. API responses with PII or unreleased schema fields shouldn't leave your browser.</li>
<li><strong>Smart nested-object flattening.</strong> Most online tools either silently drop nested objects or stringify them as <code>[object Object]</code>. Dot notation produces meaningful column names for downstream spreadsheet analysis.</li>
<li><strong>RFC 4180 compliance with UTF-8 BOM toggle.</strong> Output works correctly in Excel, Google Sheets, Numbers, and any RFC-4180 parser without manual fix-up.</li>
<li><strong>No ads, no row caps.</strong> json-csv.com caps free tier at 1,000 rows; this page handles 50,000+ rows entirely in browser memory.</li>
</ol>
<p>Pair the JSON to CSV converter with the <a href="/json-formatter">JSON Formatter</a> to validate the input first, the <a href="/yaml-to-json">YAML to JSON Converter</a> if your source is YAML (Kubernetes / Docker Compose), the <a href="/byte-converter">Byte Converter</a> for export size estimates, and the <a href="/encoding-tools">Encoding Tools hub</a> for the broader transform toolkit.</p>
</section>
<section class="faq-section"><h2>Frequently Asked Questions</h2>
<div class="faq-item open"><div class="faq-q" onclick="toggleFaq(this)">How do I convert a JSON file to CSV?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg></div><div class="faq-a">Paste your JSON <strong>array of objects</strong> into the input above. The tool automatically extracts column headers from object keys and converts each object into a CSV row. Click "Download CSV" to save the file. The JSON must be an array like <code>[{"name":"Alice"},{"name":"Bob"}]</code>. Single objects are wrapped in an array automatically.</div></div>
<div class="faq-item"><div class="faq-q" onclick="toggleFaq(this)">Can I convert nested JSON to a flat CSV?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg></div><div class="faq-a">Yes. When "Flatten nested objects" is checked, nested objects are flattened using <strong>dot notation</strong>. For example, <code>{"user":{"name":"Alice"}}</code> becomes a column <code>user.name</code> with value "Alice". Nested arrays are serialized as JSON strings in the CSV cell.</div></div>
<div class="faq-item"><div class="faq-q" onclick="toggleFaq(this)">What is the difference between JSON and CSV?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg></div><div class="faq-a"><strong>JSON</strong> is a hierarchical format supporting nested objects, arrays, and typed values (strings, numbers, booleans, null). <strong>CSV</strong> is a flat tabular format with rows and columns — everything is a string. JSON is ideal for APIs and complex data; CSV is better for spreadsheets, databases, and tabular analysis. Converting between them often requires flattening or restructuring.</div></div>
<div class="faq-item"><div class="faq-q" onclick="toggleFaq(this)">How do I open JSON data in Excel?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg></div><div class="faq-a">Convert your JSON to CSV first, then open the CSV in Excel — it auto-maps columns. Alternatively, Excel 2016+ has <strong>Power Query</strong> (Data → Get Data → From JSON) that imports JSON directly with transformation options. Google Sheets can also import CSV files via File → Import.</div></div>
<div class="faq-item"><div class="faq-q" onclick="toggleFaq(this)">Is my data safe during conversion?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg></div><div class="faq-a"><strong>Yes.</strong> All conversion happens in your browser using JavaScript. No data is uploaded, stored, or logged on any server. You can safely convert sensitive API responses, database exports, or confidential datasets.</div></div>
</section>
<section class="related-section"><h2>Related Tools</h2><div class="related-grid">
<a class="related-card" href="json-formatter"><div class="related-icon">{ }</div><div class="related-card-info"><div class="related-card-name">JSON Formatter</div><div class="related-card-desc">Pretty print and validate JSON</div></div></a>
<a class="related-card" href="string-escape"><div class="related-icon">\\</div><div class="related-card-info"><div class="related-card-name">String Escape Tool</div><div class="related-card-desc">Escape/unescape JSON strings</div></div></a>
<a class="related-card" href="text-diff"><div class="related-icon">±</div><div class="related-card-info"><div class="related-card-name">Text Diff Checker</div><div class="related-card-desc">Compare two texts side by side</div></div></a>
</div></section>
<section class="all-tools-section" aria-label="Browse all FreeDevTool developer tools">
<h2>Browse all 50 free developer tools</h2>
<p class="atc-sub">All tools run in your browser, no signup required, nothing sent to a server.</p>
<div class="all-tools-grid">
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">b64</div>
<div class="atc-cat-title"><h3>Encoding & Conversion</h3><span class="atc-cat-count">11 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/base64-encoder">Base64 Encoder / Decoder</a></li>
<li><a href="/base64-image">Image to Base64</a></li>
<li><a href="/byte-converter">Byte Converter (KB / MB / GB)</a></li>
<li><a href="/case-converter">Case Converter</a></li>
<li><a href="/hex-to-rgb">Hex to RGB / HSL</a></li>
<li><a href="/html-entity">HTML Entity Encoder</a></li>
<li><a href="/json-to-csv">JSON to CSV Converter</a></li>
<li><a href="/px-to-rem">PX to REM Converter</a></li>
<li><a href="/string-escape">String Escape / Unescape</a></li>
<li><a href="/url-encoder">URL Encoder / Decoder</a></li>
<li><a href="/yaml-to-json">YAML to JSON Converter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">{ }</div>
<div class="atc-cat-title"><h3>Formatting & Generators</h3><span class="atc-cat-count">13 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/color-name">Color Name from Hex</a></li>
<li><a href="/color-picker">Color Palette Picker</a></li>
<li><a href="/css-box-shadow">CSS Box Shadow</a></li>
<li><a href="/css-gradient">CSS Gradient Generator</a></li>
<li><a href="/json-formatter">JSON Formatter / Validator</a></li>
<li><a href="/lorem-ipsum">Lorem Ipsum Generator</a></li>
<li><a href="/markdown-preview">Markdown Preview</a></li>
<li><a href="/password-generator">Password Generator</a></li>
<li><a href="/qr-generator">QR Code Generator</a></li>
<li><a href="/sql-formatter">SQL Formatter</a></li>
<li><a href="/uuid-generator">UUID Generator</a></li>
<li><a href="/word-to-markdown">Word to Markdown</a></li>
<li><a href="/xml-formatter">XML Formatter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">JS</div>
<div class="atc-cat-title"><h3>Minifiers & DevOps</h3><span class="atc-cat-count">6 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/chmod-calculator">chmod Calculator</a></li>
<li><a href="/cron-parser">Cron Expression Parser</a></li>
<li><a href="/css-minifier">CSS Minifier</a></li>
<li><a href="/html-minifier">HTML Minifier</a></li>
<li><a href="/js-minifier">JavaScript Minifier</a></li>
<li><a href="/http-status">HTTP Status Codes</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">#</div>
<div class="atc-cat-title"><h3>Security & Hashing</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/hash-generator">Hash Generator (MD5, SHA)</a></li>
<li><a href="/jwt-decoder">JWT Decoder</a></li>
<li><a href="/jwt-generator">JWT Generator</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">.*</div>
<div class="atc-cat-title"><h3>Code & Text</h3><span class="atc-cat-count">8 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/ai-token-counter">AI Token Counter</a></li>
<li><a href="/char-counter">Character & Word Counter</a></li>
<li><a href="/git-cheatsheet">Git Commands Cheatsheet</a></li>
<li><a href="/number-base">Number Base Converter</a></li>
<li><a href="/regex-explainer">Regex Explainer</a></li>
<li><a href="/regex-tester">Regex Tester</a></li>
<li><a href="/text-diff">Text Diff Checker</a></li>
<li><a href="/wcag-contrast">WCAG Contrast Checker</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">IP</div>
<div class="atc-cat-title"><h3>Network & APIs</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/dns-lookup">DNS Lookup</a></li>
<li><a href="/http-request-builder">HTTP Request Builder</a></li>
<li><a href="/ip-lookup">IP Address Lookup</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">⏱</div>
<div class="atc-cat-title"><h3>Time & Dates</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/relative-time">Relative Time Calculator</a></li>
<li><a href="/timestamp-diff">Timestamp Diff</a></li>
<li><a href="/unix-timestamp-converter">Unix Timestamp Converter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">SEO</div>
<div class="atc-cat-title"><h3>SEO & Meta</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/meta-tag-generator">Meta Tag Generator</a></li>
<li><a href="/og-preview">Open Graph Preview</a></li>
<li><a href="/slug-generator">URL Slug Generator</a></li>
</ul>
</div>
</div>
</section>
</div>
<footer><div>© 2026 FreeDevTool — JSON to CSV Converter</div><div class="footer-links"><a href="/all-tools">All Tools</a><a href="/about">About</a><a href="/privacy">Privacy Policy</a><a href="/terms">Terms of Use</a></div></footer>
<script>
let csvData='';
function flatten(obj,prefix=''){const out={};for(const[k,v]of Object.entries(obj)){const key=prefix?prefix+'.'+k:k;if(v&&typeof v==='object'&&!Array.isArray(v))Object.assign(out,flatten(v,key));else out[key]=v}return out}
function escCsv(val,delim){const s=val==null?'':String(val);if(s.includes(delim)||s.includes('"')||s.includes('\n'))return'"'+s.replace(/"/g,'""')+'"';return s}
function convert(){const input=document.getElementById('json-input').value;const errEl=document.getElementById('json-error');const outEl=document.getElementById('csv-output');const statsEl=document.getElementById('stats');document.getElementById('input-count').textContent=input.length+' characters';
if(!input.trim()){outEl.textContent='Paste JSON above to convert...';outEl.style.fontStyle='italic';outEl.style.color='var(--text2)';errEl.style.display='none';statsEl.style.display='none';document.getElementById('download-btn').style.display='none';csvData='';return}
try{let data=JSON.parse(input);if(!Array.isArray(data))data=[data];const doFlatten=document.getElementById('flatten').checked;const delim=document.getElementById('delimiter').value;const rows=doFlatten?data.map(r=>flatten(r)):data;const headers=[...new Set(rows.flatMap(r=>Object.keys(r)))];
let csv=headers.map(h=>escCsv(h,delim)).join(delim)+'\n';rows.forEach(r=>{csv+=headers.map(h=>{let v=r[h];if(Array.isArray(v))v=JSON.stringify(v);return escCsv(v,delim)}).join(delim)+'\n'});
csvData=csv;outEl.textContent=csv;outEl.style.fontStyle='normal';outEl.style.color='var(--text)';errEl.style.display='none';statsEl.style.display='';statsEl.textContent=rows.length+' rows \u00b7 '+headers.length+' columns \u00b7 '+csv.length+' characters';document.getElementById('download-btn').style.display=''}
catch(e){errEl.style.display='';errEl.className='status status-err';errEl.textContent='\u2717 Invalid JSON: '+e.message;outEl.textContent='';statsEl.style.display='none';document.getElementById('download-btn').style.display='none';csvData=''}}
function copyOutput(){if(csvData){navigator.clipboard.writeText(csvData);showToast()}}
function downloadCSV(){if(!csvData)return;const blob=new Blob([csvData],{type:'text/csv'});const a=document.createElement('a');a.href=URL.createObjectURL(blob);a.download='data.csv';a.click()}
function showToast(){const t=document.getElementById('copy-toast');t.classList.add('show');setTimeout(()=>t.classList.remove('show'),1800)}
function toggleFaq(el){el.parentElement.classList.toggle('open')}
</script>
<script>document.addEventListener('click',e=>{const dd=document.getElementById('tools-dropdown');if(dd&&!dd.contains(e.target))dd.classList.remove('open')});</script>
</body>
</html>