Convert JSON to Excel (.xlsx) without losing zeros, digits or dates
· 5 min read · By Amir Badi
Excel can't simply open a JSON file. You either build the table in Power Query, write a script, or convert the file to .xlsx first. Each way works, and each one can quietly damage data on the way in: an ID of 007 becomes 7, a 19-digit account number loses its last digits, and a list of tags turns into Python syntax. This guide shows the three ways and how to keep the data intact.
Every Python result below was checked by opening the written .xlsx with openpyxl 3.1 (pandas 3.1, Python 3.12). The example is customers.json:
[
{ "id": "007", "name": "Ana", "account": 1234567890123456789,
"address": { "city": "Lima", "zip": "01234" }, "tags": ["vip", "beta"], "joined": "2026-03-04" },
{ "id": "042", "name": "Ben", "account": 98765,
"address": { "city": "Oslo" }, "tags": [], "joined": "2026-11-20" }
]
Decide the rows and columns
A spreadsheet is a grid, so the JSON has to become one. The usual mapping:
- One record per row. The JSON needs to be a list of objects, or an object holding one (
{"customers": [...]}). - One key per column. Keys missing from some records leave empty cells.
- Nested objects become dotted columns:
address.city,address.zip. - Lists inside a record stay in one cell as text (
vip, betaor["vip","beta"]), or become rows of a second sheet if you need to filter by them.
If the JSON is deeply nested or holds several lists, pick the list you want as rows first. Convert JSON to CSV goes through these choices in detail; they're the same for Excel.
In the browser
GigaJSON's JSON to Excel does the mapping above and writes the .xlsx in your browser, so the file isn't uploaded. Paste the JSON or open the file, check the preview of the first rows, and download.
What it writes for customers.json:
| id | name | account | address.city | address.zip | tags | joined |
|---|---|---|---|---|---|---|
| 007 | Ana | 1234567890123456789 | Lima | 01234 | ["vip","beta"] | 2026-03-04 |
| 042 | Ben | 98765 | Oslo | [] | 2026-11-20 |
Text stays text, so 007 and 01234 keep their zeros and a value starting with = isn't run as a formula. Numbers and true/false keep their type, except numbers over 15 digits, which are written as text so every digit survives. The header row is bold and stays in view as you scroll. Dates stay as the text they were in the JSON. The file opens in Excel, Google Sheets, Numbers and LibreOffice.
In Excel, with Power Query
Excel for Windows reads JSON through Power Query:
- Data > Get Data > From File > From JSON, and pick the file.
- Power Query shows a
List. Click To Table, then OK. - Click the expand button (two arrows) in the column header, choose the fields, and untick Use original column name as prefix if you want short names.
- Nested objects show as
Record: expand them the same way. Lists show asList: Extract Values joins them into text, Expand to New Rows gives one row per item. - Set each column's type in the header (ABC for text): make IDs and postcodes text before loading.
- Close & Load.
The advantage is the refresh: when the JSON file changes, Data > Refresh All reruns every step. The drawback is the clicking, which you repeat for each nested level. Power Query also guesses column types when it loads, so check that 007 hasn't become 7 before you trust the sheet.
In Python
pandas flattens the records and writes the sheet:
import json
import pandas as pd
with open("customers.json", encoding="utf-8") as f:
data = json.load(f)
df = pd.json_normalize(data) # address.city, address.zip ...
df.to_excel("customers.xlsx", index=False)
json_normalize makes the dotted columns. Opening the result shows what went through untouched and what didn't:
| Value in the JSON | Cell in the .xlsx | |
|---|---|---|
"007" |
007 (text) |
kept |
"01234" |
01234 (text) |
kept |
1234567890123456789 |
a number Excel shows as 1.23457E+18 |
last digits lost |
["vip", "beta"] |
['vip', 'beta'] (text) |
Python syntax, not JSON |
"2026-03-04" |
2026-03-04 (text) |
a text cell, not a date |
The leading zeros survive because an .xlsx stores strings as strings, unlike a CSV. The long number doesn't: it's written as a floating-point number, and Excel keeps 15 significant digits of it, so the last four digits are gone. Fix the three problems before writing:
df = pd.json_normalize(data)
df["account"] = df["account"].astype(str) # keep all 19 digits
df["tags"] = df["tags"].map(lambda v: ", ".join(v)) # a list as readable text
df["joined"] = pd.to_datetime(df["joined"]).dt.date # a real Excel date
with pd.ExcelWriter("customers.xlsx", engine="openpyxl", date_format="YYYY-MM-DD") as xl:
df.to_excel(xl, sheet_name="Customers", index=False)
xl.sheets["Customers"].freeze_panes = "A2" # header stays on screen
Now account is the text 1234567890123456789, tags reads vip, beta, joined is a date Excel can sort and filter, and the header row stays put. You need pip install pandas openpyxl first. Use json.dumps instead of ", ".join if someone will read the lists back as JSON.
Limits and gotchas
- 1,048,576 rows per sheet, the header included. pandas stops with
Row numbers must be between 1 and 1048576when you ask for more. Split the data across sheets or files (the JSON Splitter cuts a big file by record count), or stay with CSV. - 16,384 columns, 32,767 characters per cell. Wide, sparse JSON (every record with different keys) can hit the column limit, and long text fields the cell limit.
- 15 significant digits. IDs, card numbers, tracking numbers and 64-bit timestamps in nanoseconds all need to be text. Large JSON numbers explains why JSON itself can lose them before Excel ever sees them.
- Dates are text unless you convert them. JSON has no date type, so
"2026-03-04"arrives as text. That's safe, but it sorts as text. Convert on purpose, as above. - Google Sheets has no JSON import of its own. Convert to
.xlsxor CSV, then use File > Import.
Back the other way
To turn a spreadsheet into JSON, save it as CSV and use CSV to JSON, which keeps values like 007 as text. To look at the JSON as a table before you convert anything, open it in the GigaJSON app: the Table view shows a list of objects as a grid you can sort and filter, and Export writes Excel from there too.