Truncate text

Shorten long text to a maximum length, cutting from the middle, start or end and marking the cut with an ellipsis.

Input

The text to shorten.
Longest result allowed, in characters, including the marker.
Which part to cut out. "middle" keeps the start and the end.
Text that stands in for the removed part.

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/truncate-middle \
  -H 'Content-Type: application/json' \
  -d '{"input":{"text":"The quick brown fox jumps over the lazy dog","max_length":20}}'
import json, urllib.request

body = {'input': {'text': 'The quick brown fox jumps over the lazy dog', 'max_length': 20}}
request = urllib.request.Request("https://setget.net/v1/tools/truncate-middle", 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/truncate-middle", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"text":"The quick brown fox jumps over the lazy dog","max_length":20}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "truncate-middle",
  "input": {
    "text": "The quick brown fox jumps over the lazy dog",
    "max_length": 20
  }
}
{
  "input": {
    "text": "The quick brown fox jumps over the lazy dog",
    "max_length": 20
  }
}

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

Inputs

NameTypeRequiredWhat it does
text string yes The text to shorten.
max_length integer no Longest result allowed, in characters, including the marker. Default: 80. From 1 to 1000000.
where string no Which part to cut out. "middle" keeps the start and the end. One of: start, middle, end. Default: "middle".
marker string no Text that stands in for the removed part. Default: "\u2026".

Examples

Input
{
  "text": "The quick brown fox jumps over the lazy dog",
  "max_length": 20
}
Result
{
  "text": "The quick … lazy dog",
  "truncated": true,
  "original_length": 43,
  "removed": 24
}

Keeping the end of a path

Input
{
  "text": "/home/sam/projects/website/assets/images/logo.png",
  "max_length": 26,
  "where": "start",
  "marker": "..."
}
Result
{
  "text": ".../assets/images/logo.png",
  "truncated": true,
  "original_length": 49,
  "removed": 26
}

Already short enough

Input
{
  "text": "Short text",
  "max_length": 20
}
Result
{
  "text": "Short text",
  "truncated": false,
  "original_length": 10,
  "removed": 0
}

Questions

Is the marker counted in the length?
Yes. The result, marker included, is never longer than max_length.
Does it cut accented letters in half?
No. A cut never separates a letter from its combining accents, so the result can be a character or two shorter than the limit.