# Document chunker

Splits a long document into indexed chunks that can then be searched, ranked, or sent to an AI agent.

## Configuration

- **Input context key**: path to a string, JSON object, or list of strings. Type `{` to use autocomplete.
- **Split mode**:
  - **Paragraphs** keeps paragraph blocks together.
  - **Sentences** groups complete sentences.
  - **Characters** creates fixed-size windows.
- **Chunk size**: maximum number of characters per chunk, from 100 to 20,000.
- **Overlap**: characters repeated between consecutive chunks. It must be smaller than the chunk size.
- **Metadata JSON**: optional object copied into every chunk, such as a source, language, or document id.

## Safe test input

Using a list of strings avoids invalid JSON caused by a line break inside a quoted string:

```json
{
  "question": "How do I reset my password?",
  "document": [
    "Create an account with your email address.",
    "If you forgot your password, select Forgot password on the login page.",
    "A reset link is sent by email and remains valid for 30 minutes.",
    "Invoices are available from the Billing section."
  ]
}
```

Recommended test configuration:

```text
Input context key: {input.document}
Split mode: Paragraphs
Chunk size: 150
Overlap: 20
```

Document Chunker joins a list of strings with paragraph separators before splitting it.

## Output structure

```json
{
  "chunks": [
    {
      "index": 0,
      "text": "Create an account...",
      "length": 31,
      "start": 0,
      "end": 31,
      "metadata": {
        "source": "support"
      }
    }
  ],
  "count": 1,
  "chunk_size": 150,
  "overlap": 20,
  "split_mode": "paragraph"
}
```

For a Reranker placed next, select `{outputs.<chunker_id>.parsed}`, then use `chunks` as its items path and `text` as its text path.

## Runtime output

The node writes its main result to `last_output` and, when structured, to `last_output_parsed`. Downstream nodes can reference named outputs through `{outputs.<node_id>.parsed}`.

## Example workflow

Use the workflow card below to create a working example in the editor. It uses safe sample data and avoids external side effects unless the node itself is an outbound integration.

---

*Source: https://agentbuilder.systalink.sn/docs/node-document-chunker — human documentation.*
*Other language: [/docs-md/fr/node-document-chunker.md](/docs-md/fr/node-document-chunker.md).*
*Machine-readable index: [/llms.txt](/llms.txt).*
