JSON to Excel Converter
Turn a JSON array into a real XLSX file for the moment someone asks for the data and means a spreadsheet. The first object's keys set the column order, and keys that only appear in later rows become extra columns at the end. Numbers go into numeric cells, so formulas work on them. A nested object or array is written into its cell as JSON text, and an array of bare values gets a single value column.
1 JSON to Excel (XLSX) example
Input JSON
[
{
"ID": 101,
"Name": "John Doe",
"Department": "Engineering",
"Salary": 85000,
"JoinDate": "2023-01-15"
},
{
"ID": 102,
"Name": "Jane Smith",
"Department": "Marketing",
"Salary": 72000,
"JoinDate": "2023-03-20"
},
{
"ID": 103,
"Name": "Bob Johnson",
"Department": "Sales",
"Salary": 90000,
"JoinDate": "2022-11-05"
}
] Table Preview
2
3
4
ID Name Department Salary JoinDate
101 John Doe Engineering 85000 2023-01-15
102 Jane Smith Marketing 72000 2023-03-20
103 Bob Johnson Sales 90000 2022-11-05 2 Who asks for this
People who work in spreadsheets
Finance, ops and management teams want a file they can sort and filter. An endpoint and an API token do not help them.
Analysis you do not want to code
Use a pivot table for a one-off question. Load the download into Excel and a pivot table or chart usually answers it faster than a script would.
Workflow
Building an Excel workbook from JSON
- 01 The tool expects an array of objects, one per row. Paste it into the left editor, load a file with Upload JSON, or fetch it with Load URL. Dummy Data shows the expected shape.
- 02 On the right you get a tab-separated preview of the sheet. The header row starts with the first object's keys, and keys that only appear in later objects are added at the end. A nested object or array lands in its cell as JSON text.
- 03 Click Beautify input to reindent the JSON if you want to check it first.
- 04 Click Download XLSX to save a workbook with one sheet named Sheet1.
- 05 Click Copy for Spreadsheet to copy the tab-separated preview, then paste it straight into an open Excel or Google Sheets tab.
Code
How to convert JSON to an Excel XLSX file in JavaScript, Python and PHP
JavaScript (SheetJS)
js// npm install xlsx
const XLSX = require("xlsx");
const rows = [
{ id: 1, name: "Ada", joined: "2024-01-15", score: 98.5 },
{ id: 2, name: "Grace", joined: "2024-02-01", score: 91 },
];
const sheet = XLSX.utils.json_to_sheet(rows); // first object's keys = header row
const book = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(book, sheet, "Data");
XLSX.writeFile(book, "data.xlsx"); The same library runs in the browser, where XLSX.writeFile triggers a download instead of writing to disk.
Python (openpyxl)
python# pip install openpyxl
import json
from openpyxl import Workbook
rows = json.loads('[{"id":1,"name":"Ada","score":98.5},{"id":2,"name":"Grace","score":91}]')
wb = Workbook()
ws = wb.active
ws.title = "Data"
headers = list(rows[0].keys())
ws.append(headers)
for row in rows:
ws.append([row.get(h) for h in headers]) # numbers stay numeric cells
wb.save("data.xlsx") If pandas is already in the project, pd.DataFrame(rows).to_excel("data.xlsx", index=False) does all of this in one line.
PHP (PhpSpreadsheet)
php<?php
// composer require phpoffice/phpspreadsheet
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$rows = json_decode('[{"id":1,"name":"Ada","score":98.5},{"id":2,"name":"Grace","score":91}]', true);
$sheet = (new Spreadsheet())->getActiveSheet();
$sheet->fromArray(array_keys($rows[0]), null, 'A1'); // header row
$sheet->fromArray(array_map('array_values', $rows), null, 'A2');
(new Xlsx($sheet->getParent()))->save('data.xlsx'); fromArray() writes numbers as numeric cells and everything else as text.
Troubleshooting
Column flattening and date cell issues
- Excel says the file is corrupt or in a different format
- The file was saved with .xlsx but contains CSV or HTML. Only a real Office Open XML writer produces .xlsx; renaming a .csv does not.
- Dates appear as text and sorting is alphabetical
- JSON has no date type, so ISO strings such as 2024-01-15 arrive as text. Convert the column with Excel's Text to Columns, or parse the string into a Date before writing when you generate the file in code.
- Numbers show as 1.23457E+15 or lose digits
- Excel stores numbers as 64-bit floats with 15 significant digits. Write IDs, phone numbers and card numbers as strings so they are stored in text cells.
- Sheet name error: "Worksheet name cannot contain [ ] * ? / \ : and must be 31 characters or less"
- Excel limits sheet names. Trim the name and remove those characters before calling book_append_sheet or ws.title.
Format notes
Why XLSX preserves types better than CSV
An .xlsx file is a ZIP archive of XML parts, described by the Office Open XML standard (ECMA-376). Unlike CSV, it carries types: numbers, booleans, shared strings, and dates stored as serial day numbers with a number format. A string cell stays a string, so leading zeros, long IDs and Unicode text survive an .xlsx export where a CSV opened in Excel would mangle them.
Copy for Spreadsheet puts tab-separated text on the clipboard. Paste it into Excel or Google Sheets and it lands as a range of cells, which is quicker than saving and reopening a workbook for a small table.
Standards
Spreadsheet and SheetJS references
Guides
Guides and tutorials
Q&A
JSON to Excel export questions
Can I customize the column order?
The keys of the first object set the column order, and keys that first appear in later objects are added as columns at the end. To change the order, reorder the keys in the first object before converting, or move the columns in Excel after downloading.
Which Excel versions can open the file?
The output is a standard .xlsx (Office Open XML) workbook. Excel 2007 and later, Google Sheets, LibreOffice Calc and Apple Numbers all open it.
How are nested objects represented?
As JSON text in one cell. For example, an address object lands in the address column as {"city":"Oslo"}. The tool does not flatten nested fields into separate columns, so flatten the data first if you need to filter on them in Excel. A top-level array of bare values or arrays gets a single value column.
Do numbers and dates keep their type?
Numbers are written as numeric cells, so formulas work on them. JSON has no date type, so dates arrive as strings and are stored as text. Convert the column in Excel if you need date arithmetic.
Is there a row limit?
Excel allows up to 1,048,576 rows per sheet. The tool builds the workbook in memory in your browser, so for very large arrays your device's memory is a limit too.