AI & LLM

LangChain / LlamaIndex Document JSON Example

A JSON example of a LangChain / LlamaIndex Document object — page_content plus metadata such as source, page, and ids. Copy-ready for RAG loaders, splitters, and vector stores.

{
  "id": "d3f1a9c2-0b77-4e2a-9b1c-9a2e7f1c4d88",
  "page_content": "JSONKit is a free, private suite of JSON tools that run entirely in your browser.",
  "metadata": {
    "source": "docs/intro.md",
    "title": "Introduction",
    "page": 1,
    "chunk": 0,
    "created_at": "2025-05-01T00:00:00Z"
  },
  "type": "Document"
}

Field Reference

page_contentrequiredstringThe text payload of the document — what gets embedded and retrieved
metadatarequiredobjectArbitrary key–value attributes carried alongside the text (source, page, ids, tags)
metadata.sourceoptionalstringWhere the content came from — used for citations and filtering
idoptionalstringStable document/node id; LlamaIndex calls it node_id
typeoptionalstringObject type marker used by serializers ('Document')

Variants

LlamaIndex TextNodeLlamaIndex's node format with relationships and a hash.
{
  "id_": "node_8821",
  "text": "JSONKit runs entirely in your browser.",
  "metadata": {
    "source": "docs/intro.md"
  },
  "relationships": {
    "source": {
      "node_id": "doc_intro"
    }
  },
  "hash": "a1b2c3d4e5f6"
}
Loader output (array)A document loader typically returns an array of Documents, one per chunk or file.
Loader output (array)
{
  "documents": [
    {
      "page_content": "Chapter 1 text…",
      "metadata": {
        "source": "book.pdf",
        "page": 1
      }
    },
    {
      "page_content": "Chapter 2 text…",
      "metadata": {
        "source": "book.pdf",
        "page": 2
      }
    }
  ]
}

Common Use Cases

  • Loading and chunking files into a RAG pipeline with LangChain or LlamaIndex
  • Carrying source metadata through to citations in answers
  • Serializing documents to JSON for storage or transport between services
langchainllamaindexdocumentragloaderembeddings

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 Document is the core unit of text in LangChain: an object with page_content (the text) and metadata (a dict of attributes like source, page, and ids). Loaders produce Documents, splitters chunk them, and vector stores embed and index them. LlamaIndex's equivalent is a TextNode/Document with a 'text' field.

Metadata flows through the whole pipeline: it powers citations (source), filtering at query time (tenant, date, access level), and deduplication (ids/hash). Keep metadata small and consistent so it stays useful when documents are split into many chunks.

Related JSON Examples