# Text chunker

Split long text into chunks of a maximum size for search and RAG pipelines, breaking at natural boundaries.

- Endpoint: `POST https://setget.net/v1/tools/text-chunk` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `text-chunk`
- Page: https://setget.net/tools/text-chunk

## Inputs

- `text` (required, string): The text to split.
- `max_chars` (optional, integer, default `1000`, range 1..1000000): Longest chunk allowed, in characters.
- `overlap` (optional, integer, default `0`, range 0..500000): Characters repeated from the end of one chunk at the start of the next. At most half of max_chars.

## Example 1

```json
{"input":{"text":"First paragraph here.\n\nSecond paragraph is a little longer. It has two sentences.","max_chars":40}}
```

Result:

```json
{"count":3,"chunks":[{"index":0,"start":0,"end":21,"text":"First paragraph here."},{"index":1,"start":23,"end":59,"text":"Second paragraph is a little longer."},{"index":2,"start":60,"end":81,"text":"It has two sentences."}]}
```

## Example 2: With overlap

```json
{"input":{"text":"alpha beta gamma delta epsilon zeta","max_chars":16,"overlap":6}}
```

Result:

```json
{"count":4,"chunks":[{"index":0,"start":0,"end":16,"text":"alpha beta gamma"},{"index":1,"start":11,"end":22,"text":"gamma delta"},{"index":2,"start":17,"end":30,"text":"delta epsilon"},{"index":3,"start":31,"end":35,"text":"zeta"}]}
```

**Where does it break?** At the last paragraph break in the second half of the chunk. If there is none, at the last sentence end, then at the last space, and only then in the middle of a word.

**What are start and end?** Character positions in the original text, counting from 0. "end" is the position just after the chunk, and the chunk has no spaces or line breaks at its edges.

**How do I size chunks in tokens?** As a rule of thumb one token is about 4 characters of English, so 2,000 characters is roughly 500 tokens.

**Is there a limit on the number of chunks?** Yes, 10,000. Raise max_chars if you reach it.
