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
February 23, 2026 - Identical to load(), but instead of a file-like object, deserialize s (a str, bytes or bytearray instance containing a JSON document) to a Python object using this conversion table.
🌐
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)
Discussions

python - Reading JSON from a file - Stack Overflow
The distinction between undefined and empty is not always going to be made clear in JSON files. For example, several popular non-python librariesl convert empty lists (and empty dicts) into JSON null. 2024-06-25T10:43:19.273Z+00:00 ... json.loads() is still usable, but you need to modify the ... More on stackoverflow.com
🌐 stackoverflow.com
python - Loading and parsing a JSON file with multiple JSON objects - Stack Overflow
I am trying to load and parse a JSON file in Python. But I'm stuck trying to load the file: import json json_data = open('file') data = json.load(json_data) Yields: ValueError: Extra data: line 2 More on stackoverflow.com
🌐 stackoverflow.com
What is the difference between json.load() and ...
Tutorial about json.dump/dumps & json.load/loads bogotobogo.com/python/… 2019-12-10T16:17:37.16Z+00:00 More on stackoverflow.com
🌐 stackoverflow.com
JSON load() vs loads()

load() loads JSON from a file or file-like object

loads() loads JSON from a given string or unicode object

It's in the documentation

More on reddit.com
🌐 r/learnpython
7
6
October 8, 2015
🌐
freeCodeCamp
freecodecamp.org › news › how-to-use-the-json-module-in-python
How to Use the JSON Module in Python – A Beginner's Guide
June 5, 2023 - In this section, you will learn how to use the json.load() function to retrieve JSON data from a file and work with it in your Python programs.
🌐
Packetswitch
packetswitch.co.uk › python-json
The Ultimate Guide to Handling JSON with Python
July 23, 2025 - Python also provides a way to read data from a JSON file. The json.load() method is used to read data from a JSON file and convert it into a Python dictionary.
🌐
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.
Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › python › python_json.htm
Python - JSON
In the following example we are deserializing a JSON string into a Python dictionary using the json.loads() method
🌐
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
🌐
GeeksforGeeks
geeksforgeeks.org › python › read-write-and-parse-json-using-python
Read, Write and Parse JSON using Python - GeeksforGeeks
August 28, 2025 - To convert a JSON string into a Python dictionary, use the json.loads() method from Python’s built-in json module.
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.

🌐
Code-maven
python.code-maven.com › python-json › json › json-loads.html
JSON loads - Python JSON
loads · import json with open('data.json') as fh: json_str = fh.read() print(json_str) data = json.loads(json_str) print(data) {"fname": "Foo", "lname": "Bar", "email": null, "children": ["Moo", "Koo", "Roo"], "fixed": ["a", "b"]} {'fname': 'Foo', 'lname': 'Bar', 'email': None, 'children': ['Moo', 'Koo', 'Roo'], 'fixed': ['a', 'b']}
🌐
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

🌐
Medium
medium.com › @gadallah.hatem › the-difference-between-json-loads-and-json-load-2dbd30065f26
The difference between json.loads() and ...
December 15, 2024 - Feature json.loads() json.load() Input JSON string (in memory). File object or stream (on disk or in memory). Output Python object (dict, list, etc.). Python object (dict, list, etc.). Use Case Parsing JSON strings (e.g., API responses).
🌐
Code Beautify
codebeautify.org › blog › python-load-json-from-file
Python Load Json From File
March 2, 2022 - If you are a python programmer, json.load is a handy function to load data from a json file.
🌐
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.
🌐
Reintech
reintech.io › term › understanding-json-load-in-python
Understanding json.load() in Python | Reintech media
August 2, 2023 - json.load() is a method in Python's json module, used for reading JSON data from a file. It parses a file containing JSON data and converts it into a Python object. The file from which the method reads can be a .txt or .json file.
🌐
GeeksforGeeks
geeksforgeeks.org › python › read-json-file-using-python
Read JSON file using Python - GeeksforGeeks
We will be using Python’s json module, which offers several methods to work with JSON data. In particular, loads() and load() are used to read JSON from strings and files, respectively.
Published   September 15, 2025
🌐
Zyte
zyte.com › home › blog › json parsing with python [practical guide]
JSON Parsing with Python [Practical Guide]
July 6, 2023 - 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.