Text chunker

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

Input

The text to split.
Longest chunk allowed, in characters.
Characters repeated from the end of one chunk at the start of the next. At most half of max_chars.

Result

Fill in the input and press Run.

Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.

Use it from code or an agent

curl -s https://setget.net/v1/tools/text-chunk \
  -H 'Content-Type: application/json' \
  -d '{"input":{"text":"First paragraph here.\n\nSecond paragraph is a little longer. It has two sentences.","max_chars":40}}'
import json, urllib.request

body = {'input': {'text': 'First paragraph here.\n\nSecond paragraph is a little longer. It has two sentences.', 'max_chars': 40}}
request = urllib.request.Request("https://setget.net/v1/tools/text-chunk", json.dumps(body).encode(),
                                 {"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/text-chunk", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"text":"First paragraph here.\n\nSecond paragraph is a little longer. It has two sentences.","max_chars":40}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "text-chunk",
  "input": {
    "text": "First paragraph here.\n\nSecond paragraph is a little longer. It has two sentences.",
    "max_chars": 40
  }
}
{
  "input": {
    "text": "First paragraph here.\n\nSecond paragraph is a little longer. It has two sentences.",
    "max_chars": 40
  }
}

Endpoint: POST /v1/tools/text-chunk. Over MCP: run_tool with slug: "text-chunk". Machine-readable: input schema, Markdown. Connect an agent.

Inputs

NameTypeRequiredWhat it does
text string yes The text to split.
max_chars integer no Longest chunk allowed, in characters. Default: 1000. From 1 to 1000000.
overlap integer no Characters repeated from the end of one chunk at the start of the next. At most half of max_chars. Default: 0. From 0 to 500000.

Examples

Input
{
  "text": "First paragraph here.\n\nSecond paragraph is a little longer. It has two sentences.",
  "max_chars": 40
}
Result
{
  "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."
    }
  ]
}

With overlap

Input
{
  "text": "alpha beta gamma delta epsilon zeta",
  "max_chars": 16,
  "overlap": 6
}
Result
{
  "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"
    }
  ]
}

Questions

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.