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
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ json-load-in-python
json.load() in Python - GeeksforGeeks
August 11, 2025 - import json # Opening and reading the JSON file with open('data.json', 'r') as f: # Parsing the JSON file into a Python dictionary data = json.load(f) # Iterating over employee details for emp in data['emp_details']: print(emp)
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_json.asp
Python JSON
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 ยป
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ json.html
JSON encoder and decoder โ€” Python 3.14.3 documentation
4 weeks ago - As a result of this, if a dictionary is converted into JSON and then back into a dictionary, the dictionary may not equal the original one. That is, loads(dumps(x)) != x if x has non-string keys.
๐ŸŒ
Medium
medium.com โ€บ @gadallah.hatem โ€บ the-difference-between-json-loads-and-json-load-2dbd30065f26
The difference between json.loads() and json.load() in Python | by Hatem A. Gad | Medium
December 15, 2024 - import json # JSON string json_string = '{"name": "Alice", "age": 30, "is_member": true}' # Convert JSON string to Python dictionary data = json.loads(json_string) print(data) # Output: {'name': 'Alice', 'age': 30, 'is_member': True}
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ json-loads-in-python
json.loads() in Python - GeeksforGeeks
... Return Type: Returns a Python object such as dict, list, int, float, or str depending on the JSON content. Example 1: This example converts a JSON string containing user details into a Python dictionary.
Published ย  January 13, 2026
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ python json.loads() method with examples
Python json.loads() Method with Examples - Spark By {Examples}
May 31, 2024 - We can see that our json data is decoded into ordered key-value pairs. Using loads(), now convert json into python dictionary with parse_float parameter.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ json
Python JSON: Read, Write, Parse JSON (With Examples)
For example: p = '{"name": "Bob", "languages": ["Python", "Java"]}' It's also common to store a JSON object in a file. To work with JSON (string, or file containing JSON object), you can use Python's json module. You need to import the module before you can use it.
Find elsewhere
๐ŸŒ
Real Python
realpython.com โ€บ python-json
Working With JSON Data in Python โ€“ Real Python
August 20, 2025 - The Python object that you get from json.load() depends on the top-level data type of your JSON file. In this case, the JSON file contains an object at the top level, which deserializes into a dictionary. When you deserialize a JSON file as a Python object, then you can interact with it nativelyโ€”for example, by accessing the value of the "name" key with square bracket notation ([]).
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ python โ€บ json module โ€บ .load()
Python | JSON Module | .load() | Codecademy
May 29, 2025 - This example illustrates using json.load() with custom parsing options to process scientific or financial data with specific formatting requirements:
๐ŸŒ
Bogotobogo
bogotobogo.com โ€บ python โ€บ python-json-dumps-loads-file-read-write.php
Python Tutorial: json.dump(s) & json.load(s) - 2024
# write to a file with open("4forces.json","w") as f: json.dump(d, f) # reads it back with open("4forces.json","r") as f: d = json.load(f) Here is another example (json.dump()/json.load()) using simpler data:
๐ŸŒ
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 ... types. For example, JSON strings are converted to Python strings, JSON numbers are converted to Python integers or floats, and JSON arrays are converted to Python lists....
๐ŸŒ
Zyte
zyte.com โ€บ home โ€บ blog โ€บ json parsing with python [practical guide]
JSON Parsing with Python [Practical Guide]
July 6, 2023 - 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 objects such as lists and dictionaries. Next is an example on how to convert JSON string to a Python object with the loads method.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ json load() vs loads()
r/learnpython on Reddit: JSON load() vs loads()
November 24, 2013 -

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

๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Learn_web_development โ€บ Core โ€บ Scripting โ€บ JSON
Working with JSON - Learn web development | MDN
Note: We've made the JSON seen above available inside a variable in our JSONTest.html example (see the source code). Try loading this up and then accessing data inside the variable via your browser's JavaScript console.
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ python โ€บ json_load_function.htm
Python json.load() Function
import json # Custom function to transform JSON objects def custom_decoder(obj): return {key.upper(): value for key, value in obj.items()} # Open the JSON file for reading with open('data.json', 'r') as file: # Deserialize JSON data with custom object_hook data = json.load(file, object_hook=custom_decoder) print("Transformed Data:", data) We obtain the following converted custom Python objects in our file โˆ’ ยท Transformed Data: {'NAME': 'John', 'AGE': 30, 'CITY': 'New York'} In this example, we use the parse_int and parse_float parameters to customize how numbers are processed while loading JSON data โˆ’
๐ŸŒ
Quora
quora.com โ€บ What-is-the-usage-of-Json-load-and-JSON-loads-in-Python
What is the usage of Json.load and JSON.loads in Python? - Quora
Answer (1 of 2): The difference is in the source of the JSON text * [code ]json.load()[/code] expects to get the text from a file-like object * [code ]json.loads()[/code] expects to get its text from a string object Assume you have a file (json.txt) with the following contents [code][ {"name"...
Top answer
1 of 6
306

Yes, s stands for string. The json.loads function does not take the file path, but the file contents as a string. Look at the documentation.

Simple example:

with open("file.json") as f:
  data = json.load(f)  # ok

  data = json.loads(f)  # not ok, f is not a string but a file
text = '{"a": 1, "b": 2}'  # a string with json encoded data
data = json.loads(text) 
2 of 6
138

Just going to add a simple example to what everyone has explained,

json.load()

json.load can deserialize a file itself i.e. it accepts a file object, for example,

# open a json file for reading and print content using json.load
with open("/xyz/json_data.json", "r") as content:
  print(json.load(content))

will output,

{u'event': {u'id': u'5206c7e2-da67-42da-9341-6ea403c632c7', u'name': u'Sufiyan Ghori'}}

If I use json.loads to open a file instead,

# you cannot use json.loads on file object
with open("json_data.json", "r") as content:
  print(json.loads(content))

I would get this error:

TypeError: expected string or buffer

json.loads()

json.loads() deserialize string.

So in order to use json.loads I will have to pass the content of the file using read() function, for example,

using content.read() with json.loads() return content of the file,

with open("json_data.json", "r") as content:
  print(json.loads(content.read()))

Output,

{u'event': {u'id': u'5206c7e2-da67-42da-9341-6ea403c632c7', u'name': u'Sufiyan Ghori'}}

That's because type of content.read() is string, i.e. <type 'str'>

If I use json.load() with content.read(), I will get error,

with open("json_data.json", "r") as content:
  print(json.load(content.read()))

Gives,

AttributeError: 'str' object has no attribute 'read'

So, now you know json.load deserialze file and json.loads deserialize a string.

Another example,

sys.stdin return file object, so if i do print(json.load(sys.stdin)), I will get actual json data,

cat json_data.json | ./test.py

{u'event': {u'id': u'5206c7e2-da67-42da-9341-6ea403c632c7', u'name': u'Sufiyan Ghori'}}

If I want to use json.loads(), I would do print(json.loads(sys.stdin.read())) instead.