DEV Community

Imad Uddin
Imad Uddin

Posted on

How to Convert JSON to Excel — Python, Online Tool & No-Code Methods

Got JSON data you need in a spreadsheet? Here's how to get there.

Python with pandas (fastest)

import pandas as pd
import json

with open("data.json") as f:
    data = json.load(f)

df = pd.DataFrame(data)
df.to_excel("output.xlsx", index=False)
print("Done.")
Enter fullscreen mode Exit fullscreen mode

Install deps first:

pip install pandas openpyxl
Enter fullscreen mode Exit fullscreen mode

Handling nested JSON

Nested objects need flattening first:

from pandas import json_normalize

with open("data.json") as f:
    data = json.load(f)

df = json_normalize(data)  # flattens nested keys with dot notation
df.to_excel("output.xlsx", index=False)
Enter fullscreen mode Exit fullscreen mode

Nested key address.city becomes column address.city in your spreadsheet.

Node.js option

const XLSX = require("xlsx");
const data = require("./data.json");

const ws = XLSX.utils.json_to_sheet(data);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
XLSX.writeFile(wb, "output.xlsx");
Enter fullscreen mode Exit fullscreen mode
npm install xlsx
Enter fullscreen mode Exit fullscreen mode

No-code option

The free JSON to Excel tool converts your JSON to a properly formatted .xlsx file in seconds — paste your JSON or upload a file, click convert, download.

No Python, no Node, no setup.

Top comments (0)