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
🌐
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…
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 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
29
8
October 1, 2025
CSV to JSON - Not quite
I thought JSON was always key value pairs and the values were always strings, now I have to be able to export a CSV file to “JSON” using specific data types for each field These are the data types for each key:value pair [{“FIELD_1”: String, “FIELD_2”: Int, “FIELD_1”: Int, ... More on discuss.python.org
🌐 discuss.python.org
0
0
June 27, 2022
🌐
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.
🌐
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.
🌐
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...
🌐
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
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 213 users
Languages   Python
🌐
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.
🌐
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.
🌐
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.
🌐
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.
🌐
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.
🌐
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 …
🌐
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.
🌐
Python.org
discuss.python.org › python help
CSV to JSON - Not quite - Python Help - Discussions on Python.org
June 27, 2022 - I thought JSON was always key value pairs and the values were always strings, now I have to be able to export a CSV file to “JSON” using specific data types for each field These are the data types for each key:value pair [{“FIELD_1”: String, “FIELD_2”: Int, “FIELD_1”: Int, ...
🌐
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.