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
🌐
Python
docs.python.org β€Ί 3 β€Ί library β€Ί json.html
JSON encoder and decoder β€” Python 3.14.3 documentation
3 weeks ago - Return a JSON string representation of a Python data structure, o. For example: >>> json.JSONEncoder().encode({"foo": ["bar", "baz"]}) '{"foo": ["bar", "baz"]}' ... Encode the given object, o, and yield each string representation as available.
🌐
Readthedocs
jsonlines.readthedocs.io
jsonlines β€” jsonlines documentation
The original line itself is stored on the exception instance as the .line attribute, and the line number as .lineno. This class subclasses both jsonlines.Error and the built-in ValueError.
Discussions

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
Python conversion from JSON to JSONL - Stack Overflow
If you have a list of JSONs, like in your example, you can still search and replace with RegEx, take the negative lookahead "?!", see Stack Overflow Find 'word' not followed by a certain character with \n(?!\s*\{) so that you also skip the spaces after a linebreak: ... Clean the rest of the unneeded characters as you showed it yourself, but take RegEx for it, and you could also do this RegEx replacement automatically with Python ... More on stackoverflow.com
🌐 stackoverflow.com
September 19, 2022
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
How do you print json data in multiply lines?
Use the pprint module. from pprint import pprint response = requests.get(url) x = json.loads(response.text) pprint(x) (BTW json is just the vehicle; there's no such type as "json data". The data you have is just standard python lists and dictionaries.) Edit: the json module also has this feature: import json response = requests.get(url) x = json.loads(response.text) print(json.dumps(x, indent=2)) More on reddit.com
🌐 r/learnpython
10
5
December 4, 2021
🌐
PyPI
pypi.org β€Ί project β€Ί json-lines
json-lines Β· PyPI
Handling broken (cut at some point) files is enabled by passing broken=True to json_lines.reader or json_lines.open. Broken lines are skipped (only logging a warning), and reading continues from the next valid position.
      Β» pip install json-lines
    
Published Β  Nov 21, 2018
Version Β  0.5.0
🌐
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 - It’s a file type specification where each line is a JSON object. Just imagine a bunch of stacked up dictionaries. Here’s an example with 4 records:
🌐
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 - JSON data often takes the form of newline-delimited JSON Lines (also known as NDJSON) to represent multiple records in a dataset. Reading JSON Lines data into a dataframe is a common first step in data processing. In this post, we compare the performance and functionality of Python APIs for ...
🌐
Softhints
softhints.com β€Ί python-convert-json-to-json-lines
Python convert normal JSON to JSON separated lines 3 examples - Softhints
February 10, 2022 - import jsonlines import json with open('/home/user/data/normal_json.json', 'r') as f: json_data = json.load(f) with jsonlines.open('/home/user/data/json_lines2.jl', 'w') as writer: writer.write_all(json_data) ... {"id": 1, "label": "A", "size": "S"} {"id": 2, "label": "B", "size": "XL"} {"id": 3, "label": "C", "size": "XXl"} ...
Find elsewhere
🌐
GitHub
github.com β€Ί rmoralespp β€Ί jsonl
GitHub - rmoralespp/jsonl: A lightweight Python library for handling jsonlines files Β· GitHub
2 weeks ago - When reading, if the file extension is not recognized, jsonl falls back to magic-number detection to identify the compression format automatically. # Install dev dependencies pip install --group=test --upgrade # Run tests python -m pytest tests/ python -m pytest tests/ --cov # run with coverage reporting # Lint pip install --group=lint --upgrade ruff check .
Author Β  rmoralespp
🌐
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 - See how to open JSONL files in a spreadsheet, read JSONL in python, convert JSON to JSONL and CSV to JSONL, and the advantages of JSON lines format.
🌐
GitHub
github.com β€Ί wbolster β€Ί jsonlines
GitHub - wbolster/jsonlines: python library to simplify working with jsonlines and ndjson data
python library to simplify working with jsonlines and ndjson data - wbolster/jsonlines
Starred by 307 users
Forked by 31 users
Languages Β  Python 100.0% | Python 100.0%
🌐
Real Python
realpython.com β€Ί python-json
Working With JSON Data in Python – Real Python
August 20, 2025 - For example, a string in line 2, a Boolean in line 3, a NoneType in line 7, and a tuple in line 8, just to name a few. Next, convert dog_data to a JSON-formatted string and back to Python again.
🌐
NCBI
ncbi.nlm.nih.gov β€Ί datasets β€Ί docs β€Ί v2 β€Ί reference-docs β€Ί file-formats β€Ί metadata-files β€Ί tools-for-jsonl
Tools for JSON and JSON Lines - NCBI
JSON Lines is less widely adopted; however, the format consists of one JSON value per line, and therefore, is easily parsed with JSON libraries. For example, in Python:
🌐
Jsonltools
jsonltools.com β€Ί jsonl-parser
JSONL Parser: Complete Guide to Parsing JSON Lines Format - JSONL Tools
Learn how to parse JSONL files with comprehensive examples in Python, JavaScript, Java, and Go. Complete guide to JSONL parsing with performance tips and best practices.
🌐
freeCodeCamp
freecodecamp.org β€Ί news β€Ί how-to-parse-json-in-python-with-examples
How to Parse JSON in Python – A Complete Guide With Examples
October 29, 2025 - The final example shows that valid JSON parses successfully and returns a dictionary instead of None. JSON parsing failed: Expecting ',' delimiter Error at line 1, column 19 Result 1: None JSON parsing failed: Expecting ',' delimiter Error at line 1, column 28 Result 2: None JSON parsing failed: Expecting property name enclosed in double quotes Error at line 1, column 29 Result 3: None Result 4: {'name': 'Sarah', 'age': 28}
🌐
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 β€Ί how do you print json data in multiply lines?
r/learnpython on Reddit: How do you print json data in multiply lines?
December 4, 2021 -

Currently trying to get some data from a url which shows in json format, i can get the data, however when i print it, it just shows in 1 long line of text which isnt what i want. i want the text to be split into multiply lines like when you add \n to strings. (i know its normally not good to do except Exceptions, its just there while i get the other part to work, also the entire def is in a class)

Here is what i currently have. I havent work much with json data before which is why im stuck at what exactly to do.

def info(self):
      try:
            url = [url]
            response = requests.get(url)
            x = json.loads(response.text)
            lore = str(x['data'][input_champion]['lore'])
            print('Getting champion info, please wait')
            time.sleep(5)
            print(f'lore:  {lore}')
            time.sleep(0.5)

      except Exception as e:
            time.sleep(5)
🌐
Jsonlines
jsonlines.org β€Ί examples
JSON Lines |Examples
December 2, 2025 - JSON Lines enables applications to read objects line-by-line, with each line fully describing a JSON object. The example above contains the same data as the tabular example above, but allows applications to split files on newline boundaries for parallel loading, and eliminates any ambiguity ...
🌐
Jsonlines
jsonlines.org β€Ί on_the_web
JSON Lines |On The Web
November 2, 2024 - OpenAI Evals is an AI Evaluations (Evals) application using JSON Lines to pass in bulk data. petl is a general purpose Python package for extracting, transforming and loading tables of data.