With the pandas library, this is as easy as using two commands!

df = pd.read_json()

read_json converts a JSON string to a pandas object (either a series or dataframe). Then:

df.to_csv()

Which can either return a string or write directly to a csv-file. See the docs for to_csv.

Based on the verbosity of previous answers, we should all thank pandas for the shortcut.

For unstructured JSON see this answer.

EDIT: Someone asked for a working minimal example:

import pandas as pd

with open('jsonfile.json', encoding='utf-8') as inputfile:
    df = pd.read_json(inputfile)

df.to_csv('csvfile.csv', encoding='utf-8', index=False)
Answer from vmg on Stack Overflow
Top answer
1 of 16
281

With the pandas library, this is as easy as using two commands!

df = pd.read_json()

read_json converts a JSON string to a pandas object (either a series or dataframe). Then:

df.to_csv()

Which can either return a string or write directly to a csv-file. See the docs for to_csv.

Based on the verbosity of previous answers, we should all thank pandas for the shortcut.

For unstructured JSON see this answer.

EDIT: Someone asked for a working minimal example:

import pandas as pd

with open('jsonfile.json', encoding='utf-8') as inputfile:
    df = pd.read_json(inputfile)

df.to_csv('csvfile.csv', encoding='utf-8', index=False)
2 of 16
152

First, your JSON has nested objects, so it normally cannot be directly converted to CSV. You need to change that to something like this:

{
    "pk": 22,
    "model": "auth.permission",
    "codename": "add_logentry",
    "content_type": 8,
    "name": "Can add log entry"
},
......]

Here is my code to generate CSV from that:

import csv
import json

x = """[
    {
        "pk": 22,
        "model": "auth.permission",
        "fields": {
            "codename": "add_logentry",
            "name": "Can add log entry",
            "content_type": 8
        }
    },
    {
        "pk": 23,
        "model": "auth.permission",
        "fields": {
            "codename": "change_logentry",
            "name": "Can change log entry",
            "content_type": 8
        }
    },
    {
        "pk": 24,
        "model": "auth.permission",
        "fields": {
            "codename": "delete_logentry",
            "name": "Can delete log entry",
            "content_type": 8
        }
    }
]"""

x = json.loads(x)

f = csv.writer(open("test.csv", "wb+"))

# Write CSV Header, If you dont need that, remove this line
f.writerow(["pk", "model", "codename", "name", "content_type"])

for x in x:
    f.writerow([x["pk"],
                x["model"],
                x["fields"]["codename"],
                x["fields"]["name"],
                x["fields"]["content_type"]])

You will get output as:

pk,model,codename,name,content_type
22,auth.permission,add_logentry,Can add log entry,8
23,auth.permission,change_logentry,Can change log entry,8
24,auth.permission,delete_logentry,Can delete log entry,8
🌐
GeeksforGeeks
geeksforgeeks.org › python › convert-json-to-csv-in-python
Convert JSON to CSV in Python - GeeksforGeeks
July 12, 2025 - We can convert JSON to CSV in Python using the built-in json and csv modules.
Discussions

Convert json to csv or XML ?
Csv is probably a simpler format to work with. I would start with writing a script that simply prints out with a loop the json file. Then modify the code in that loop to instead write it to a file comma separated (string manipulation). I'm sure if you googled or asked chatgpt you could get the basics of this pretty quick. More on reddit.com
🌐 r/DatabaseHelp
31
2
March 29, 2024
How to transform a JSON file into a CSV one in Python?
Hi Everyone, I have a quick question. Thanks to a previous post : Python: Extract Data from an Interactive Map on the Web, with Several Years, into a CSV file I was been able to extract JSON data from the web. Thanks again to @FelixLeg & @kknechtel to their useful help and advices. More on discuss.python.org
🌐 discuss.python.org
14
0
April 8, 2024
Converting JSON to .csv file
Sure you could make your own json to csv conversion code, and it would probably be a lot faster to run than using the pandas intermediate. But if what you have is working I wouldn't recommend changing it. It's probably not worth 2 hours of your time writing better code just to save 1 second of runtime. More on reddit.com
🌐 r/learnpython
30
8
October 1, 2025
Convert csv in json with python
You can use the package "ast" Just do x = ast.literal_eval(row['all_points_x']) Should transfer it properly. More on reddit.com
🌐 r/learnpython
8
8
May 1, 2021
🌐
GitHub
github.com › vinay20045 › json-to-csv
GitHub - vinay20045/json-to-csv: Nested JSON to CSV Converter · GitHub
Nested JSON to CSV Converter. This python script converts valid, preformatted JSON to CSV which can be opened in excel and other similar applications. This script can handle nested json with multiple objects and arrays.
Starred by 290 users
Forked by 212 users
Languages   Python
🌐
Gigasheet
gigasheet.com › post › convert-json-to-csv-python
How to Convert JSON to CSV in Python
How to Convert JSON to CSV in Python by Syed Hasan | Learn how to convert JSON to CSV using Python code and Pandas functions, and the the #NoCode way of converting JSON to CSV using Gigasheet.
🌐
LearnPython.com
learnpython.com › blog › python-json-to-csv
How to Convert JSON to CSV in Python | LearnPython.com
JSON and CSV are two different file formats, but you can convert between them in Python. We’ll show you how in this article.
Find elsewhere
🌐
Python.org
discuss.python.org › python help
How to transform a JSON file into a CSV one in Python? - Python Help - Discussions on Python.org
April 8, 2024 - Hi Everyone, I have a quick question. Thanks to a previous post : Python: Extract Data from an Interactive Map on the Web, with Several Years, into a CSV file I was been able to extract JSON data from the web. Thanks again to @FelixLeg & @kknechtel to their useful help and advices.
🌐
CodeGym
codegym.cc › java blog › learning python › convert json to csv in python
Convert JSON to CSV in Python
July 31, 2024 - In this article, we've explored how to convert JSON to CSV in Python using both the built-in json and csv libraries, as well as the more powerful Pandas library.
🌐
DEV Community
dev.to › tooldeck › how-to-convert-json-to-csv-in-python-complete-guide-3mhg
How to Convert JSON to CSV in Python (Complete Guide) - DEV Community
March 31, 2026 - No pip install, no virtual environment gymnastics. csv.DictWriter takes a list of dictionaries and writes each one as a CSV row, mapping dict keys to column headers. The fieldnames parameter controls both the column order and which keys get included. # Python 3.8+ — minimal json to csv example import json import csv # Sample JSON data — an array of order objects json_string = """ [ {"order_id": "ord_91a3", "product": "Wireless Keyboard", "quantity": 2, "unit_price": 74.99}, {"order_id": "ord_b7f2", "product": "USB-C Hub", "quantity": 1, "unit_price": 34.50}, {"order_id": "ord_c4e8", "produ
🌐
Medium
medium.com › @alexaae9 › how-to-convert-json-to-csv-in-python-a-complete-guide-d039f0d5a9a5
How to Convert JSON to CSV in Python: A Complete Guide | by Alexander Stock | Medium
September 15, 2025 - Convert JSON to CSV in Python with ease. Learn to export fields, handle missing keys, and flatten nested data into clean, structured CSV files.
🌐
Squash
squash.io › how-to-convert-json-to-csv-in-python
How to Convert JSON to CSV in Python - Squash Labs
A guide for converting JSON to CSV using Python, suitable for any level of expertise.
🌐
InventiveHQ
inventivehq.com › home › blog › python › convert json to csv in python: complete guide with examples
Convert JSON to CSV in Python: Complete Guide with Examples
November 27, 2025 - Convert JSON to CSV and back using Python's json, csv, and pandas libraries. Includes nested JSON handling, error handling, and production-ready code examples.
Address   2305 Historic Decatur Rd, Suite 100, 92106, San Diego
🌐
Medium
medium.com › @gabrielpires › how-to-convert-a-json-file-to-csv-python-script-a9ff0a3f906e
How to convert a JSON file to CSV — PYTHON SCRIPT | by Gabriel Pires | Medium
May 6, 2020 - import csv, json, sys #if you are not using utf-8 files, remove the next line sys.setdefaultencoding("UTF-8") #set the encode to utf8 #check if you pass the input file and output file if sys.argv[1] is not None and sys.argv[2] is not None: fileInput = sys.argv[1] fileOutput = sys.argv[2] inputFile = open(fileInput) #open json file outputFile = open(fileOutput, 'w') #load csv file data = json.load(inputFile) #load json content inputFile.close() #close the input file output = csv.writer(outputFile) #create a csv.write output.writerow(data[0].keys()) # header row for row in data: output.writerow(row.values()) #values row
🌐
Tutor Python
tutorpython.com › convert-json-to-csv-in-python
Here is how to Convert JSON to CSV in Python - Tutor Python
December 25, 2023 - To convert JSON data to CSV file using Python, you can use libraries such as json and csv.
🌐
Medium
medium.com › @harikrishnank497 › converting-json-to-csv-using-python-66c38826a751
Converting JSON to CSV Using Python | by Harikrishnan K | Medium
July 1, 2024 - Converting JSON to CSV Using Python import json import csv import os def convert_json_to_csv(input_json_file, output_csv_folder): # Ensure the output folder exists …
🌐
Bright Data
brightdata.com › faqs › json › convert-json-data-to-csv
How to convert JSON data to a CSV file in Python?
July 15, 2024 - This guide will show you how to convert JSON data to a CSV file in Python using various methods.
🌐
GitHub
github.com › udayansawant › json-csv
GitHub - udayansawant/json-csv: Converting JSON to CSV in Python · GitHub
To convert JSON to CSV in Python, use the pandas to_csv() function. The to_csv() is a Pandas library function you can use in Python that writes objects to a comma-separated values (csv) file.
Author   udayansawant
🌐
EDUCBA
educba.com › home › software development › software development tutorials › python tutorial › convert json to csv in python
JSON to CSV Python | How to Convert JSON to CSV in Python
August 23, 2025 - And also csv module methods such as DictWriter() to write data to CSV files. To convert any JSON file to a CSV file using Python programming language, we have to make JSON keys as headers to convert it into a CSV file.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai