# Wrap and indent text

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

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

## Inputs

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

## Example 1

```json
{"input":{"text":"The quick brown fox jumps over the lazy dog.","width":20,"prefix":"> "}}
```

Result:

```json
{"text":"> The quick brown\n> fox jumps over the\n> lazy dog.","lines":3}
```

## Example 2: Indent only

```json
{"input":{"text":"def f():\n    return 1","width":0,"indent":4}}
```

Result:

```json
{"text":"    def f():\n        return 1","lines":2}
```

## Example 3: Reflow paragraphs

```json
{"input":{"text":"one\ntwo\nthree\n\nfour","width":12,"reflow":true}}
```

Result:

```json
{"text":"one two\nthree\n\nfour","lines":4}
```

**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.
