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
280

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

Converting JSON to CSV
Hi, iโ€™m trying to convert JSON to CSV. So far i have the following code, which i mostly found here. #! python3 # r: numpy, pandas, json import rhinoscriptsyntax as rs import pandas as pd import json as json # Reading โ€ฆ More on discourse.mcneel.com
๐ŸŒ discourse.mcneel.com
0
0
March 14, 2024
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
25
2
February 12, 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
29
8
October 1, 2025
Best way to automate JSON to CSV/Relational Tables at scale? Anyone have used Flexter?
However, we have need to do this at scale for multiple sources which are dynamic in nature. Not trying to be pithy here but if they're truly dynamic as in you have potentially new and changing columns at any time you're fucked, and no tool is going to change that. If this is the case, you'll need to revisit your jobs with every new, unexpected column addition. Is the data you have coming in genuinely dynamic, or is it simply complex but consistent? If the latter, you can strictly define the columns and jsonpaths you pull data from. We do that in BigQuery with our nested JSON data. More on reddit.com
๐ŸŒ r/dataengineering
28
9
March 10, 2022
๐ŸŒ
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. Thankโ€ฆ
๐ŸŒ
Gigasheet
gigasheet.com โ€บ post โ€บ convert-json-to-csv-python
How to Convert JSON to CSV in Python
You can use a language like Python and code the conversion using libraries like Pandas. If youโ€™re not fond of coding, weโ€™ve got a much easier route. You can use Gigasheet. In this article, weโ€™ll walk through you through both ways to convert JSON to CSV, using Python code as well as the the #NoCode way of converting JSON to CSV.
๐ŸŒ
GitHub
github.com โ€บ jhsu98 โ€บ json-csv-converter
GitHub - jhsu98/json-csv-converter: Python script to convert between JSON and CSV files ยท GitHub
Python script to convert between JSON and CSV files - jhsu98/json-csv-converter
Starred by 23 users
Forked by 20 users
Languages ย  Python
๐ŸŒ
McNeel Forum
discourse.mcneel.com โ€บ scripting
Converting JSON to CSV - Scripting - McNeel Forum
March 14, 2024 - Hi, iโ€™m trying to convert JSON to CSV. So far i have the following code, which i mostly found here. #! python3 # r: numpy, pandas, json import rhinoscriptsyntax as rs import pandas as pd import json as json # Reading JSON data from a file with open("data.json") as f: json_data = json.load(f) # Converting JSON data to a pandas DataFrame df = pd.read_json(json_data) # Writing DataFrame to a CSV file df.to_csv("output.csv", index=False) It throws up the error: Error building code | Err...
Find elsewhere
๐ŸŒ
LearnPython.com
learnpython.com โ€บ blog โ€บ python-json-to-csv
How to Convert JSON to CSV in Python | LearnPython.com
May 22, 2023 - JSON and CSV are two different file formats, but you can convert between them in Python. Weโ€™ll show you how in this article.
๐ŸŒ
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 214 users
Languages ย  Python
๐ŸŒ
Data to Fish
datatofish.com โ€บ json-string-to-csv-python
How to Convert JSON String to CSV using Python
import os import pandas as pd ... df.to_csv(desktop_path + "/fish_lifespan.csv", index=False) Create a new file using a text editor of your choice, copy-paste the above Python code into it, and save it as json2csv.py on your desktop....
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ pandas โ€บ pandas โ€“ convert json to csv
Pandas - Convert JSON to CSV - Spark By {Examples}
November 1, 2024 - Convert JSON to CSV using Pandas, Pandas is a library in Python that can be used to convert JSON (String or file) to CSV file, all you need is first read the JSON into a pandas DataFrame and then write pandas DataFrame to CSV file.
๐ŸŒ
Verpex
verpex.com โ€บ blog โ€บ website tips โ€บ how to convert json to...
How to Convert JSON to CSV in Python
Convert JSON to CSV in Python easily. Step-by-step guide with examples using pandas and json libraries for simple and nested data.
๐ŸŒ
Inventive HQ
inventivehq.com โ€บ home โ€บ blog โ€บ python โ€บ json to csv python converter | transform and export data with code
JSON to CSV Python Converter | Transform and Export Data with Code
November 1, 2025 - Convert JSON to CSV in Python with complete code examples. Handle nested data, preserve types, and automate data transformation for analysis and reporting.
๐ŸŒ
Automate the Boring Stuff
automatetheboringstuff.com โ€บ 2e โ€บ chapter16
Chapter 16 โ€“ Working with CSV Files and JSON Data
The csv and json modules greatly simplify the process of reading and writing to CSV and JSON files. The last few chapters have taught you how to use Python to parse information from a wide variety of file formats. One common task is taking data from a variety of formats and parsing it for the particular information you need.
๐ŸŒ
Enterprise DNA
blog.enterprisedna.co โ€บ python-convert-json-to-csv
Python: Convert JSON to CSV, Step-by-Step Guide โ€“ Master Data Skills + AI
Using pandas can be quick and easy, but itโ€™s not the only tool in the Python toolbox. Another option is to use the json2csv library, which provides a simple command-line interface for converting JSON files to CSV format.
๐ŸŒ
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 โ€ฆ
๐ŸŒ
Geekflare
geekflare.com โ€บ development โ€บ how to convert json to csv in python: a step-by-step guide from experts
How to Convert JSON to CSV in Python: A Step-by-Step Guide from Experts
January 17, 2025 - Use Libraries โ€“ If the data is small, you can write a custom Python code to convert it into CSV, but in the case of large data, you should use a Python library like Pandas to efficiently convert JSON to CSV.
๐ŸŒ
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.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ convert-csv-to-json-using-python
Convert CSV to JSON using Python - GeeksforGeeks
April 28, 2025 - Let's explore different methods to convert CSV data into JSON format. The following is an example of our input.csv file: ... This is the most basic and standard approach using built-in Python libraries. It reads CSV data into dictionaries and writes it out as a JSON file.