You have a JSON Lines format text file. You need to parse your file line by line:

import json

data = []
with open('file') as f:
    for line in f:
        data.append(json.loads(line))

Each line contains valid JSON, but as a whole, it is not a valid JSON value as there is no top-level list or object definition.

Note that because the file contains JSON per line, you are saved the headaches of trying to parse it all in one go or to figure out a streaming JSON parser. You can now opt to process each line separately before moving on to the next, saving memory in the process. You probably don't want to append each result to one list and then process everything if your file is really big.

If you have a file containing individual JSON objects with delimiters in-between, use How do I use the 'json' module to read in one JSON object at a time? to parse out individual objects using a buffered method.

Answer from Martijn Pieters on Stack Overflow
๐ŸŒ
Readthedocs
jsonlines.readthedocs.io
jsonlines โ€” jsonlines documentation - Read the Docs
Read and decode a line. The optional type argument specifies the expected data type. Supported types are dict, list, str, int, float, and bool. When specified, non-conforming lines result in InvalidLineError. By default, input lines containing null (in JSON) are considered invalid, and will cause InvalidLineError.
Discussions

python - How to read line-delimited JSON from large file (line by line) - Stack Overflow
Also, Python can't seem to properly allocate memory for an object built from 2GB of data, is there a way to construct each JSON object as I'm reading the file line by line? More on stackoverflow.com
๐ŸŒ stackoverflow.com
reading a json file; readline() works as predicted, readlines() does not.
You should check out the json library. No need to read the lines individually. http://docs.python.org/2/library/json.html Edit: listen to what u/dAnjou said. You may still have to read each line to to be able to load it with json.loads(string) More on reddit.com
๐ŸŒ r/learnpython
8
2
February 19, 2013
Read JSON Lines file as String in Python - Stack Overflow
Why are you trying to load a single ... a single line wouldn't necessarily be syntactically-valid JSON) and subsequently append the resulting object to a string? Why not just read the entire file in with readlines() then use json.loads() on the resulting string to serialize it into Python data ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
February 3, 2024
Reading a large (30.6G) JSONL file
There's no good off-the-shelf solution for this. JSON files are simply not designed for that. There's a couple of "lazy" json parsers or "iterative" parsers, but in the end it comes down to what your data looks like. It's often better / easier to parse out the higher objects yourself. For example if your data is a massive list of lists, you could manually search for the "[]" characters and pass the results into json.loads as a "stream". More on reddit.com
๐ŸŒ r/learnpython
14
5
April 21, 2021
๐ŸŒ
PyPI
pypi.org โ€บ project โ€บ json-lines
json-lines ยท PyPI
This is a tiny library for reading JSON lines (.jl) files, including gzipped and broken files.
      ยป pip install json-lines
    
Published ย  Nov 21, 2018
Version ย  0.5.0
๐ŸŒ
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
๐ŸŒ
Tim Santeford
timsanteford.com โ€บ posts โ€บ how-to-read-and-parse-jsonl-files-in-python
How to Read and Parse JSONL Files in Python - Tim Santeford
January 1, 2025 - Iterating over lines: The file is read line by line to conserve memory, especially useful for large files. Parsing JSON: The json.loads function converts a JSON string into a Python dictionary (or list, depending on the content).
Find elsewhere
๐ŸŒ
Real Python
realpython.com โ€บ python-json
Working With JSON Data in Python โ€“ Real Python
August 20, 2025 - Learn how to work with JSON data in Python using the json module. Convert, read, write, and validate JSON files and handle JSON data for APIs and storage.
๐ŸŒ
Medium
sundararamanp.medium.com โ€บ a-relatively-faster-approach-for-reading-json-lines-file-into-pandas-dataframe-90b57353fd38
A relatively faster approach for reading json lines file into pandas dataframe | by Sundararaman Parameswaran | Medium
April 22, 2020 - Step 3: Now we will apply json loads function on each row of the โ€˜json_elementโ€™ column. โ€˜json.loadsโ€™ is a decoder function in python which is used to decode a json object into a dictionary.
๐ŸŒ
Rowzero
rowzero.com โ€บ blog โ€บ open-jsonl-file-format
Easily Open JSONL Files - Guide to JSON Lines Format - Row Zero โ€“ the spreadsheet for modern cloud data
October 24, 2024 - # Guide to JSONL and Python Python and JSON lines are often used together to work with big datasets. Here are a few how-tos to get started. It's easy to open and read JSONL files in Python using the Python json or jsonlines library
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ json.html
json โ€” JSON encoder and decoder
3 weeks ago - Deserialize fp to a Python object using the JSON-to-Python conversion table. ... fp (file-like object) โ€“ A .read()-supporting text file or binary file containing the JSON document to be deserialized.
๐ŸŒ
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 - Python's built-in json module makes it straightforward to parse JSON from files and strings, as well as serialize Python objects back to JSON. The simplest way to read a JSON file is with json.load():
๐ŸŒ
Unpaywall
support.unpaywall.org โ€บ support โ€บ solutions โ€บ articles โ€บ 44001867300-how-do-i-read-jsonl-files-
How do I read JSONL files? : Unpaywall
February 25, 2020 - You'll need some kind of wrapper script to handle the file line by line. In python, you could either read the file line by line and use the standard json.loads function on each line, or use the jsonlines library to do this for you.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ reading a json file; readline() works as predicted, readlines() does not.
r/learnpython on Reddit: reading a json file; readline() works as predicted, readlines() does not.
February 19, 2013 -

The json is twitter stream

here is my code:

    output = open("path\\filename.json","r")
    output.readline()

works as expected. When I use readline(), each time, a new line from the twitter stream is printed.

But this code

    output.readlines()

yields this:

ERROR - failed to write data to stream pyreadline.console.console.Console object at 0x010B9FB0

Why isn't readlines reading all of the lines?

For what it's worth, I want to read all of the lines from the twitterStream json, and then be able to select some lines (maybe randomly, maybe the first 10) to save as a new json file.

๐ŸŒ
PYnative
pynative.com โ€บ home โ€บ python โ€บ json โ€บ python parse multiple json objects from file
Python Parse multiple JSON objects from file | Solve ValueError: Extra data
February 2, 2024 - Read the file line by line because each line contains valid JSON. i.e., read one JSON object at a time. Convert each JSON object into Python dict using a json.loads()
๐ŸŒ
Medium
nicholaszhan.com โ€บ line-em-up-a-guide-to-json-lines-7c43215b3b82
Line โ€™Em Up: A Guide to JSON Lines | by Nicholas Zhan | Medium
August 5, 2025 - You can do this programmatically ...(json_line + '\n') To read the JSON Lines file and process each entry, we can iterate over the lines in the file: # Reading from a JSON Lines file with open('sensor_data.jso...
๐ŸŒ
Medium
galea.medium.com โ€บ how-to-love-jsonl-using-json-line-format-in-your-workflow-b6884f65175b
How to Love jsonl โ€” using JSON Lines in your Workflow | by Alex Galea | Medium
April 9, 2024 - I use jsonl for dumping raw โ€œsource of truthโ€ data. From there it can be loaded in and processed by any part of the application and, if needed, dumped into a relational format (e.g. Postgres, MySQL, CSV). Here are python functions that can be used to write and read jsonl:
๐ŸŒ
NVIDIA Developer
developer.nvidia.com โ€บ blog โ€บ json-lines-reading-with-pandas-100x-faster-using-nvidia-cudf
JSON Lines Reading with pandas 100x Faster Using NVIDIA cuDF | NVIDIA Technical Blog
April 23, 2025 - The runs with pylibcudf used a CUDA async memory resource through RAPIDS Memory Manager (RMM). Throughput values were computed using the JSONL input file size and the reader runtime of the third repetition. Here are some examples from several Python libraries for invoking the JSON Lines reader: