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 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.
People also ask

Who uses JSONL files?
JSON Lines files are often used by data engineers, data scientists, and analysts because JSONL is good at processing and managing large datasets. JSONL is good for real-time data and streaming applications.
๐ŸŒ
rowzero.com
rowzero.com โ€บ blog โ€บ open-jsonl-file-format
Easily Open JSONL Files - Guide to JSON Lines Format | Row Zero
What is the best way to visualize JSONL data?
Row Zero is a good JSONL viewer because it opens JSONL files in a spreadsheet format that makes it easy to view, filter, analyze, and troubleshoot large datasets.
๐ŸŒ
rowzero.com
rowzero.com โ€บ blog โ€บ open-jsonl-file-format
Easily Open JSONL Files - Guide to JSON Lines Format | Row Zero
What is the JSONL file format?
The JSON Lines format stores one JSON object per line and is a very efficient file format for large datasets.
๐ŸŒ
rowzero.com
rowzero.com โ€บ blog โ€บ open-jsonl-file-format
Easily Open JSONL Files - Guide to JSON Lines Format | Row Zero
๐ŸŒ
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
๐ŸŒ
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
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).
๐ŸŒ
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
Find elsewhere
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
Rowzero
rowzero.com โ€บ blog โ€บ open-jsonl-file-format
Easily Open JSONL Files - Guide to JSON Lines Format | Row Zero
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
๐ŸŒ
Unpaywall
support.unpaywall.org โ€บ support โ€บ solutions โ€บ articles โ€บ 44001867300-how-do-i-read-jsonl-files-
How do I read JSONL files? : Unpaywall
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.
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ json.html
JSON encoder and decoder โ€” Python 3.14.3 documentation
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.
๐ŸŒ
PYnative
pynative.com โ€บ home โ€บ python โ€บ json โ€บ python parse multiple json objects from file
Python Parse multiple JSON objects from file | Solve ValueError: Extra data
May 14, 2021 - 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()
๐ŸŒ
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 25, 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.

๐ŸŒ
Medium
nicholaszhan.com โ€บ line-em-up-a-guide-to-json-lines-7c43215b3b82
Line โ€™Em Up: A Guide to JSON Lines | by Nicholas Zhan | Medium
February 2, 2024 - 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...
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ python-read-json-file-how-to-load-json-from-a-file-and-parse-dumps
Python Read JSON File โ€“ How to Load JSON from a File and Parse Dumps
October 27, 2020 - It is installed automatically when you install Python and it includes functions to help you work with JSON files and strings. We will use this module in the coming examples. To use json in our program, we just need to write an import statement at the top of the file. ... With this line, you will ...
๐ŸŒ
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:
๐ŸŒ
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: