To parse a JSON response in Python using the requests library, use the response.json() method. This method automatically converts the JSON response into a Python dictionary, allowing you to access data using standard dictionary syntax.

Key points:

  • Use response.json() directly after making a request:

    import requests
    response = requests.get('https://api.example.com/data')
    data = response.json()
    print(data['key'])
  • Always check the response status before parsing:

    response.raise_for_status()  # Raises an exception for bad status codes
    data = response.json()
  • Handle potential errors with a try-except block:

    try:
        data = response.json()
    except requests.exceptions.JSONDecodeError:
        print("Response is not valid JSON")

This approach is preferred over json.loads(response.text) because response.json() handles encoding automatically and is more concise.

Since you're using requests, you should use the response's json method.

import requests

response = requests.get(...)
data = response.json()

It autodetects which decoder to use.

Answer from pswaminathan on Stack Overflow
🌐
W3Schools
w3schools.com › python › python_json.asp
Python JSON
The result will be a Python dictionary. ... import json # some JSON: x = '{ "name":"John", "age":30, "city":"New York"}' # parse x: y = json.loads(x) # the result is a Python dictionary: print(y["age"]) Try it Yourself »
Discussions

Why Parse JSON With Python When Pandas Exists?
Pandas works well if you have JSON that is more or less a “record” — I.e. depth of 1 with a single value per field. Pandas is all about getting it into a dataframe, which is essentially a table. JSON can represent a lot more complicated objects. If you don’t have JSON that’s a “record” you’ll probably end up fighting against pandas. What’s your end objective? What are you trying to do with the JSON? More on reddit.com
🌐 r/learnpython
23
0
December 28, 2023
How to check if something is in a JSON object before running if statement
There's no such thing as a "JSON object." There's a JSON string, which represents an object, but once you've deserialized the string you're holding a regular Python dictionary or list. So all of the regular Python membership tests work - you test whether the collection contains a key or a value by using in. The issue that I have run into so that sometimes those attributes (like subtitle) don't exist in the JSON because they do not exist in the file. if "subtitle" not in record or record["subtitle"] != "French": add_french_subtitles(record) # or whatever More on reddit.com
🌐 r/learnpython
11
6
September 15, 2023
[Python] How to parse JSon response from a post request (Requests)
If I run your code I get NameError on session, maybe you need to define that for it to work? More on reddit.com
🌐 r/learnprogramming
9
2
March 2, 2017
Parsing Json:API responses with Pydantic
Considering it's an OpenAPI spec you can simply use Pydantic datamodel code generation to build all the parsing models for you automagically. And the example they show should show you how nested models work. More on reddit.com
🌐 r/learnpython
5
1
November 12, 2022
🌐
OpenWeatherMap
openweathermap.org › current
Current weather data
Response format. JSON format is used by default.
🌐
DZone
dzone.com › coding › languages › python: parsing a json http chunking stream
Python: Parsing a JSON HTTP Chunking Stream
December 4, 2015 - I use Python for most of my hacking these days and if HTTP requests are required the requests library is my first port of call. I started out with the following script: import requests import json def stream_meetup_initial(): uri = "http://stream.meetup.com/2/rsvps" response = requests.get(uri, stream = True) for chunk in response.iter_content(chunk_size = None): yield chunk for raw_rsvp in stream_meetup_initial(): print raw_rsvp try: rsvp = json.loads(raw_rsvp) except ValueError as e: print e continue ·
🌐
GeeksforGeeks
geeksforgeeks.org › python › read-write-and-parse-json-using-python
Read, Write and Parse JSON using Python - GeeksforGeeks
August 28, 2025 - If you have JSON data stored in a .json file (for example, downloaded from an API or stored locally), Python's json module makes it easy to read and convert it into a Python dictionary using the json.load() function.
🌐
Rowell Dionicio
rowelldionicio.com › parsing-json-with-python
Parsing JSON with Python – Rowell Dionicio
May 13, 2020 - We’re printing the JSON data to the screen but we’re going to serialize that data using json.dumps and sort it with indentation. Now we’re going to comment out print(response.text) since we no longer need the print out of the raw JSON format.
Find elsewhere
🌐
GitHub
googleapis.github.io › python-genai
Google Gen AI SDK documentation
user_profile = { 'properties': { 'age': { 'anyOf': [ {'maximum': 20, 'minimum': 0, 'type': 'integer'}, {'type': 'null'}, ], 'title': 'Age', }, 'username': { 'description': "User's unique name", 'title': 'Username', 'type': 'string', }, }, 'required': ['username', 'age'], 'title': 'User Schema', 'type': 'object', } response = client.models.generate_content( model='gemini-2.5-flash', contents='Give me a random user profile.', config={ 'response_mime_type': 'application/json', 'response_json_schema': user_profile }, ) print(response.parsed)
🌐
PYnative
pynative.com › home › python › json › parse a json response using python requests library
Parse a JSON response using Python requests library
May 14, 2021 - Learn how to parse JSON response using the requests library. Access data from JSON response directly using a key. Access Nested JSON key directly from response.
🌐
Bright Data
brightdata.com › blog › how-tos › parse-json-data-with-python
Guide to Parsing JSON Data With Python
September 16, 2025 - Note that the .json() method automatically transforms the response object containing JSON data into the respective Python data structure. Great! You now know how to parse a JSON API response in Python with both urllib and requests.
🌐
GitHub
github.com › openai › openai-python
GitHub - openai/openai-python: The official Python library for the OpenAI API · GitHub
To stream the response body, use .with_streaming_response instead, which requires a context manager and only reads the response body once you call .read(), .text(), .json(), .iter_bytes(), .iter_text(), .iter_lines() or .parse().
Starred by 30.3K users
Forked by 4.7K users
Languages   Python
🌐
DataCamp
datacamp.com › tutorial › json-data-python
Python JSON Data: A Guide With Examples | DataCamp
December 3, 2024 - The if response.status_code == 200: line checks if the response code is 200, which means the request was successful. If the request is successful, the code then loads the response text into a Python dictionary using the json.loads() method and stores it in the data variable.
🌐
Zyte
zyte.com › home › blog › json parsing with python [practical guide]
JSON Parsing with Python [Practical Guide]
July 6, 2023 - To read JSON data, you can use the built-in json module (JSON Encoder and Decoder) in Python. The json module provides two methods, loads and load, that allow you to parse JSON strings and JSON files, respectively, to convert JSON into Python ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › response-json-python-requests
response.json() - Python requests - GeeksforGeeks
July 12, 2025 - When we print the response it prints '<Response [200]>' which is the HTTP code that indicates success. To print the JSON data fetched we have used json() method which prints the JSON data in the Python dictionary format as seen in the output. In this way, we can pas parse JSON responses in Python.
🌐
Axios
axios-http.com › docs › intro
Getting Started | Axios Docs
Automatic JSON data handling in response · Progress capturing for browsers and node.js with extra info (speed rate, remaining time) Setting bandwidth limits for node.js · Compatible with spec-compliant FormData and Blob (including node.js) Client side support for protecting against XSRF ·
🌐
Openai
developers.openai.com › api › docs › guides › structured-outputs
Structured model outputs | OpenAI API
You can use the parse method to automatically parse the JSON response into the object you defined.
🌐
W3Schools
w3schools.com › python › gloss_python_json_parse.asp
Python JSON Parse
The result will be a Python dictionary. ... import json # some JSON: x = '{ "name":"John", "age":30, "city":"New York"}' # parse x: y = json.loads(x) # the result is a Python dictionary: print(y["age"]) Try it Yourself »
🌐
freeCodeCamp
freecodecamp.org › news › how-to-parse-json-in-python-with-examples
How to Parse JSON in Python – A Complete Guide With Examples
October 29, 2025 - JSON arrays represent ordered lists of values and appear frequently in API responses when returning collections of items. Python converts JSON arrays into lists, which you can iterate through or access by index. Here's an example parsing a list of products from an inventory system:
🌐
Google
developers.google.com › google maps platform › web services › geocoding api › geocoding api overview
Geocoding API overview | Google for Developers
The Java Client, Python Client, Go Client and Node.js Client for Google Maps Services are community-supported client libraries, open sourced under the Apache 2.0 License. Download them from GitHub, where you can also find installation instructions and sample code. Start using the Geocoding API: Go to Set up your Google Cloud project. Get started with sample requests and responses: Go to Geocoding requests and responses
🌐
freeCodeCamp
freecodecamp.org › news › python-parse-json-how-to-read-a-json-file
Python Parse JSON – How to Read a JSON File
February 7, 2022 - We can then parse the file using the json.load() method and assign it to a variable called fcc_data. ... The final step would be to print the results. ... If we examine the printed data, then we should see that the JSON data prints all on one line.
🌐
Schulich School of Engineering
schulich.libguides.com › c.php
Parsing JSON Responses in Python - Getting Started With APIs - SSE Tech Support at Schulich School of Engineering - University of Calgary
July 30, 2024 - # Import the requests library import requests # Define parameters for continent and city params = { "continent": "Africa", "city": "Casablanca" } # Construct the API endpoint URL using the provided continent and city url = "http://worldtimeapi.org/api/timezone/" # Make a GET request to the API json_response = requests.get(url + f"{params['continent']}/{params['city']}") # Print the unparsed JSON response print(json_response) ... Notice that this code gives us the status code as a response instead of the current time in Casablanca like we want it to. Now let's add a little more code to parse the JSON response and see where that gets us: