AI & LLM

RAG Document Chunk JSON Example

A JSON example of a retrieval-augmented generation (RAG) document chunk — includes text, embedding reference, source metadata, and a relevance score. Copy-ready for building RAG pipelines.

{
  "id": "doc_4821#chunk_3",
  "text": "To reset your password, open Settings → Security and click 'Reset password'. You'll receive an email with a secure link that expires after 30 minutes.",
  "score": 0.8731,
  "metadata": {
    "documentId": "doc_4821",
    "title": "Resetting your password",
    "source": "help-center/account.md",
    "url": "https://help.example.com/account/reset-password",
    "chunkIndex": 3,
    "tokenCount": 38,
    "headingPath": [
      "Account",
      "Security",
      "Passwords"
    ],
    "updatedAt": "2025-04-18T09:00:00Z"
  },
  "embeddingModel": "text-embedding-3-small"
}

Field Reference

idrequiredstringStable chunk id, often documentId plus a chunk suffix
textrequiredstringThe chunk's raw text — what gets injected into the LLM context window
scoreoptionalnumberRelevance/similarity score from the retriever (0–1 for cosine). Higher is closer
metadata.sourcerequiredstringWhere the chunk came from — used for citations and filtering
metadata.chunkIndexrequiredintegerOrder of this chunk within the source document
metadata.tokenCountoptionalintegerTokens in the chunk — used to budget the context window

Variants

Retriever responseA ranked list of chunks returned for a query, ready to assemble into context.
{
  "query": "how do I reset my password",
  "chunks": [
    {
      "id": "doc_4821#chunk_3",
      "score": 0.8731,
      "text": "To reset your password, open Settings → Security…"
    },
    {
      "id": "doc_1190#chunk_0",
      "score": 0.7402,
      "text": "Password requirements: at least 12 characters…"
    }
  ],
  "retrievedAt": "2025-05-20T14:22:05Z"
}

Common Use Cases

  • Chunking documents and storing them for retrieval in a RAG pipeline
  • Returning cited sources alongside an LLM answer
  • Filtering retrieval by metadata such as source, date, or access level
ragretrievalchunkvector searchcontextllm

Validate or format this JSON

One click loads this exact example into the tool — no copy-paste needed. Format it, validate it, explore the tree, or generate TypeScript types instantly.

Frequently Asked Questions

A common sweet spot is 200–500 tokens with some overlap (10–20%) between adjacent chunks so context isn't lost at boundaries. Smaller chunks improve retrieval precision; larger chunks preserve more context per result. Tune to your documents.

Metadata powers citations ('source'), recency filtering ('updatedAt'), access control, and re-ranking. It also lets you show users where an answer came from, which is essential for trust in RAG systems.

For transport you can include it, but in practice the vector is stored in a vector database keyed by the chunk id, while this JSON keeps the text and metadata. That keeps payloads small and avoids shipping 1500-dimension arrays around.

Related JSON Examples