The json.load() method (without "s" in "load") can read a file directly:

import json

with open('strings.json') as f:
    d = json.load(f)
    print(d)

You were using the json.loads() method, which is used for string arguments only.


The error you get with json.loads is a totally different problem. In that case, there is some invalid JSON content in that file. For that, I would recommend running the file through a JSON validator.

There are also solutions for fixing JSON like for example How do I automatically fix an invalid JSON string?.

Answer from ubomb on Stack Overflow
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ json.html
json โ€” JSON encoder and decoder
cls (a JSONDecoder subclass) โ€“ If set, a custom JSON decoder. Additional keyword arguments to load() will be passed to the constructor of cls. If None (the default), JSONDecoder is used.
๐ŸŒ
OneUptime
oneuptime.com โ€บ home โ€บ blog โ€บ how to read and write json files in python
How to Read and Write JSON Files in Python
January 25, 2026 - # data = eval(json_string) # Allows code execution # Safe - Always do this data = json.loads(json_string) When loading JSON from untrusted sources, validate the structure:
๐ŸŒ
Coddy.Tech
coddy.tech โ€บ learn โ€บ courses โ€บ python json โ€บ json.loads()
json.loads() โ€“ Python JSON | Coddy
September 11, 2024 - The function takes a JSON-formatted string as input and returns a corresponding Python object. ... import json json_string = '{"name": "John", "age": 30, "city": "New York"}' parsed_data = json.loads(json_string) print(type(parsed_data)) # Output: <class 'dict'> print(parsed_data) # Output: {'name': 'John', 'age': 30, 'city': 'New York'}
Find elsewhere
๐ŸŒ
Bobdc
bobdc.com โ€บ blog โ€บ pythonjson
Parsing JSON with Python
December 15, 2024 - #!/usr/bin/env python3 import json f = open('jsondemo.js') data = json.load(f) print(data["mydata"]["color"]) print(data["mydata"]["amount"]) # Pull something out of the middle of an array print(data["mydata"]["arrayTest"][3]) print(data["mydata"]["boolTest"]) print(data["mydata"]["nullTest"]) # Use a boolean value if data["mydata"]["boolTest"]: print("So boolean!") # Dig down into a data structure print(data["mydata"]["addressBookEntry"]["address"]["city"]) print("-- mydata properties: --") for p in data["mydata"]: print(p) print("-- list addressBookEntry property names and values: --") for p in data["mydata"]["addressBookEntry"]: print(p + ': ' + str(data["mydata"]["addressBookEntry"][p])) # Testing whether values are present.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_json.asp
Python JSON
Python has a built-in package called json, which can be used to work with JSON data. ... If you have a JSON string, you can parse it by using the json.loads() method.
๐ŸŒ
NetworkAcademy
networkacademy.io โ€บ learning path: ccna automation (200-901) ccnaauto โ€บ data formats and data models โ€บ parsing json with python
Parsing JSON with Python | NetworkAcademy.IO
The with statement is a python control-flow structure that simplifies the process of reading and closing the file. Note that we use the load method instead of loads because this is a file.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ json-loads-in-python
json.loads() in Python - GeeksforGeeks
Explanation: json.loads(s) parses the JSON string s and converts it into a Python dict.
Published: January 13, 2026
๐ŸŒ
YouTube
youtube.com โ€บ corey schafer
Python Tutorial: Working with JSON Data using the json Module - YouTube
In this Python Programming Tutorial, we will be learning how to work with JSON data. We will learn how to load JSON into Python objects from strings and how ...
Published: November 20, 2017
Views: 499K
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ json load() vs loads()
r/learnpython on Reddit: JSON load() vs loads()
October 8, 2015 -

Can someone explain what the difference is between using either load() or loads() is with the JSON library? And which, if either, is the preferred method.

I'm writing a simple script where I want the JSON data from a URL parsed out into a list. Both of these options seem to work:

import json
import urllib2

url = "string to url"

response = urllib2.urlopen(url)
data = json.load(response)

or

import json
import urllib2

url = "string to url"

response = urllib2.urlopen(url)
data = json.loads(response.read())

I know that there are other libraries available for parsing out JSON data, but for the time being I'm working only with the json and urllib2 libraries.

Any insight into which one should be used?

Thanks

๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ json-data-python
Python JSON Data: A Guide With Examples | DataCamp
December 3, 2024 - This function is used to read a JSON file and parse its contents into a Python object. The load() function takes a single argument, the file object, and returns a Python object.
๐ŸŒ
Zyte
zyte.com โ€บ home โ€บ blog โ€บ json parsing with python [practical guide]
JSON Parsing with Python [Practical Guide]
December 3, 2024 - We load the data using the with open() context manager and json.load() to load the contents of the JSON file into a Python dictionary.
๐ŸŒ
JSON Formatter
jsonformatter.org โ€บ json-viewer
JSON Viewer Online Best and Free
Validate JSON using PHP ยท Python Load Json From File ยท Best and Secure JSON Viewer works well in Windows, Mac, Linux, Chrome, Firefox, Safari and Edge. Step 1: Open JSON Viewer tool using this link JSON Viewer. Step 2: Click on Load Data, ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ read-json-file-using-python
Read JSON file using Python - GeeksforGeeks
If the file does not exist, Python raises a FileNotFoundError. The except FileNotFoundError block catches the error and displays a meaningful message instead of showing a traceback. 2. Handling JSONDecodeError: A JSONDecodeError occurs when the JSON file contains invalid or improperly formatted JSON data. ... import json try: with open("data.json", "r") as file: data = json.load(file) print("File data =", data) except json.JSONDecodeError: print("Error: Invalid JSON format in the file.")
Published: July 1, 2026
๐ŸŒ
Analytics Vidhya
analyticsvidhya.com โ€บ home โ€บ python json.loads() and json.dump() methods
Python json.loads() and json.dump() methods - Analytics Vidhya
May 1, 2025 - The json.loads() function automatically converts JSON data types to their corresponding Python data types. For example, JSON strings are converted to Python strings, JSON numbers are converted to Python integers or floats, and JSON arrays are ...
๐ŸŒ
Real Python
realpython.com โ€บ python-json
Working With JSON Data in Python โ€“ Real Python
August 20, 2025 - How can you read JSON data from a file into a Python program?Show/Hide ยท You can use the json.load() function to deserialize JSON data from a file into a Python object.