> ## Documentation Index
> Fetch the complete documentation index at: https://docs.eigenpal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Text Chunker

> Split long text into chunks with regex-anchored boundaries, overlap, and header preservation. Accepts raw text or a parsed-document object; chunks carry source page indexes when pages are provided.

`transform.text-chunker`, Split long text into chunks with regex-anchored boundaries, overlap, and header preservation. Accepts raw text or a parsed-document object; chunks carry source page indexes when pages are provided.

## Configuration

Configuration goes inside the step's `with:` block.

<ParamField path="input" type="string | record<string, unknown>" required>
  Either raw text or a parsed-document object `&#123; pages: [&#123; pageIndex, text }] }` (e.g. `&#123;&#123; steps.parse.output }}`). Pages preserve per-chunk page provenance.
</ParamField>

<ParamField path="maxChars" type="integer" required>
  Target chunk size in characters. Hard ceiling per chunk is 1.5×.
</ParamField>

<ParamField path="overlap" type="integer" default="0">
  Characters duplicated at chunk boundaries (default 0). Must be \< maxChars / 2.
</ParamField>

<ParamField path="splitOn" type="array<string>">
  Ordered list of regexes; the first that matches near the chunk boundary wins. Falls back to char-cut when none match. Tip: list narrowest first (e.g. /\d+.\d+\s+/ before /\n\n+/).
</ParamField>

<ParamField path="maxChunks" type="integer" default="64">
  Safety cap; later chunks are dropped and `summary.truncated` flips to true.
</ParamField>

<ParamField path="preserveHeader" type="integer" default="0">
  Prepend the first N characters of the input to every chunk (good for "always include the contract title").
</ParamField>

<ParamField path="minChunkChars" type="integer" default="0">
  Trailing chunks shorter than this are merged into the previous chunk.
</ParamField>

## Output

<ResponseField path="chunks" type="array<object>" required>
  <Expandable title="chunks properties">
    <ResponseField path="text" type="string" required />

    <ResponseField path="index" type="integer" required />

    <ResponseField path="total" type="integer" required />

    <ResponseField path="startOffset" type="integer" required />

    <ResponseField path="endOffset" type="integer" required />

    <ResponseField path="pages" type="array<integer>" required>
      Page indexes that contributed text to this chunk (empty for raw-string input).
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField path="summary" type="object" required>
  <Expandable title="summary properties">
    <ResponseField path="inputChars" type="integer" required />

    <ResponseField path="totalChunks" type="integer" required />

    <ResponseField path="avgChunkChars" type="integer" required />

    <ResponseField path="maxChunkChars" type="integer" required />

    <ResponseField path="truncated" type="boolean" required />
  </Expandable>
</ResponseField>
