Wrap and indent text

Hard-wrap text to a line width, add or remove indentation, and put a prefix such as "> " on every line.

Input

The text to wrap or indent.
Longest line allowed, counting the indent and prefix. 0 leaves line lengths alone.
Spaces to add to every line. A negative number removes up to that many leading spaces.
Text put at the start of every line, for example "> " or "# ".
Join the lines of each paragraph before wrapping, so short lines are filled up.
First remove the indentation that all lines have in common.

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

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

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

Inputs

NameTypeRequiredWhat it does
text string yes The text to wrap or indent.
width integer no Longest line allowed, counting the indent and prefix. 0 leaves line lengths alone. Default: 80. From 0 to 10000.
indent integer no Spaces to add to every line. A negative number removes up to that many leading spaces. Default: 0. From -100 to 100.
prefix string no Text put at the start of every line, for example "> " or "# ". Default: "".
reflow boolean no Join the lines of each paragraph before wrapping, so short lines are filled up. Default: false.
dedent boolean no First remove the indentation that all lines have in common. Default: false.

Examples

Input
{
  "text": "The quick brown fox jumps over the lazy dog.",
  "width": 20,
  "prefix": "> "
}
Result
{
  "text": "> The quick brown\n> fox jumps over the\n> lazy dog.",
  "lines": 3
}

Indent only

Input
{
  "text": "def f():\n    return 1",
  "width": 0,
  "indent": 4
}
Result
{
  "text": "    def f():\n        return 1",
  "lines": 2
}

Reflow paragraphs

Input
{
  "text": "one\ntwo\nthree\n\nfour",
  "width": 12,
  "reflow": true
}
Result
{
  "text": "one two\nthree\n\nfour",
  "lines": 4
}

Questions

Are long words split?
Only when a single word is longer than the width. Otherwise lines break at spaces.
What happens to a line's own indentation?
It is kept, and the continuation lines created by wrapping get the same indentation.
How is width measured?
In characters. Wide characters such as Chinese or emoji count as one, so they may look wider on screen.