JSON Reader

Convert JSON files into knowledge base documents with JSONReader.

JSONReader creates one source document for a top-level object or each item in a top-level array, then applies fixed-size chunking.

json_reader.py
import json
from pathlib import Path

from agno.knowledge.reader.json_reader import JSONReader

reader = JSONReader()

json_path = Path("tmp/test.json")
json_path.parent.mkdir(parents=True, exist_ok=True)
json_path.write_text(
    json.dumps([{"name": "Jordan"}, {"name": "Taylor"}]),
    encoding="utf-8",
)

documents = reader.read(json_path)
for document in documents:
    print(document.meta_data["page"], document.content)

Run the Reader

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno

Run the script

python json_reader.py

Reader Parameters

ParameterTypeDefaultDescription
chunking_strategyOptional[ChunkingStrategy]FixedSizeChunking()Strategy used to chunk documents

JSONReader also accepts the base Reader constructor parameters.

Use a top-level object or array. In the current reader, number, boolean, and null roots raise a TypeError, and a string root splits into one document per character.

JSONReader.async_read() runs the synchronous reader in a worker thread.

Next Steps

TaskGuide
Configure fixed-size chunkingFixed-Size Chunking
Inspect the complete APIJSON Reader Reference
Compare available readersReaders Overview