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 encoder and decoder โ€” Python 3.14.8 documentation
>>> import json >>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]') ['foo', {'bar': ['baz', None, 1.0, 2]}] >>> json.loads('"\\"foo\\bar"') '"foo\x08ar' >>> from io import StringIO >>> io = StringIO('["streaming API"]') >>> json.load(io) ['streaming API']
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ json-load-in-python
json.load() in Python - GeeksforGeeks
April 3, 2026 - It reads JSON data from a file and converts it into the corresponding Python object.
Find elsewhere
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ python โ€บ json module โ€บ .load()
Python | JSON Module | .load() | Codecademy
May 29, 2025 - The .load() method in Pythonโ€™s JSON module is used to parse JSON data from a file-like object and convert it into a Python object. This method reads JSON content directly from files, such as .json files, and transforms the structured data ...
๐ŸŒ
Real Python
realpython.com โ€บ python-json
Working With JSON Data in Python โ€“ Real Python
August 20, 2025 - As a rule of thumb, you work with json.loads() when your data is already present in your Python program.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ json-loads-in-python
json.loads() in Python - GeeksforGeeks
json.loads() is a function from Pythonโ€™s built-in json module that converts a JSON-formatted string into a corresponding Python object.
Published: January 13, 2026
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python
Load, Parse, Serialize JSON Files and Strings in Python | note.nkmk.me
August 6, 2023 - You can use json.load() to load JSON files into Python objects, such as dictionaries.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_json.asp
Python JSON
If you have a JSON string, you can parse it by using the json.loads() method.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ loading-a-json-file-in-python-how-to-read-and-parse-json
Loading a JSON File in Python โ€“ How to Read and Parse JSON
July 25, 2022 - The json module also has the load method which you can use to read a file object and parse it at the same time.
๐ŸŒ
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 in Python is used to parse a JSON string and convert it into a Python object. It takes a JSON string as input and returns a corresponding Python object.
๐ŸŒ
Jedox
knowledgebase.jedox.com โ€บ integration โ€บ loads โ€บ json-load.htm
JSON Load
The JSON load simply executes the HTTP call as defined in the REST connection.
๐ŸŒ
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

๐ŸŒ
Bogotobogo
bogotobogo.com โ€บ python โ€บ python-json-dumps-loads-file-read-write.php
Python Tutorial: json.dump(s) & json.load(s) - 2024
import json # dict from a string : json.loads(string) with open("bogo.json","r") as f: a = f.read() s_d = json.loads(a) print(f"type(s_d) = {type(s_d)}, sd = {s_d}") # dict from a file : json.load(file Pointer) f_d = json.load(open("bogo.json","r")) print(f"type(f_d) = {type(f_d)}, fd = {f_d}") # dump dict as a string d_s = json.dumps(s_d) print(f"type(ds_) = {type(d_s)}, ds = {d_s}") # dump dict as a file json.dump(f_d, open("bogo_dumped.json","w"))
๐ŸŒ
Processing
processing.org โ€บ examples โ€บ loadsavejson
Loading JSON Data / Examples / Processing.org
This example demonstrates how to use loadJSON() to retrieve data from a JSON file and make objects from that data.