# Text wrap width

`text-wrap-width` · version 1.0.0 · Text · free, no key needed

Hard-wrap text by Unicode code-point width and return the resulting lines.

**Use when you need to: wrap text at a fixed width · hard wrap a string · split text into width limited lines.**

## Decide before calling

Read the [versioned contract](/v1/tools/text-wrap-width/versions/1.0.0) and the supported scope below. Reuse `text-wrap-width@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `text-wrap-width@1.0.0` for wrap text at a fixed width. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- wrap text at a fixed width
- hard wrap a string
- split text into width limited lines
- break long words into lines
- format text to a character width
- wrap Unicode text by code points

## Not supported

- grapheme-cluster display width
- Unicode line-breaking opportunity analysis

## Behavior

- Width counts Unicode code points, not UTF-16 units, graphemes, columns, or bytes.
- CRLF and CR become LF; LF forces a break; ASCII spaces and tabs between words collapse to one space.
- When break_long_words is false, an indivisible word may exceed width.
- Reference: Unicode 16.0.0, UAX #14 Revision 55; this tool uses explicit rules rather than claiming UAX #14 conformance.

## Input

- `text` (string, required): max length 4096
- `width` (integer, required): min 1; max 256
- `break_long_words` (boolean, required)

## Output

- `lines` (array of string, required): max items 4096
- `standard_version` (constant "Unicode 16.0.0", required)

## Limits

- max input bytes: 4096
- max width: 256
- max lines: 4096
- max output bytes: 16384

## Example

Request input:

```json
{
  "text": "alpha beta gamma",
  "width": 10,
  "break_long_words": true
}
```

Response:

```json
{
  "result": {
    "lines": [
      "alpha beta",
      "gamma"
    ],
    "standard_version": "Unicode 16.0.0"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "text-wrap-width",
  "version": "1.0.0",
  "input": {
    "text": "alpha beta gamma",
    "width": 10,
    "break_long_words": true
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/text-wrap-width/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"text":"alpha beta gamma","width":10,"break_long_words":true}'
```

The machine-readable contract is at [/v1/tools/text-wrap-width/versions/1.0.0](/v1/tools/text-wrap-width/versions/1.0.0).

### CLI

```sh
node cli.mjs run text-wrap-width 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Text paragraphs split](/tools/text-paragraphs-split): Split text into paragraphs separated by blank lines (CommonMark line rules) with code point spans and line numbers.
- [Markdown sections chunk](/tools/markdown-sections-chunk): Chunk a CommonMark document into sections at its top-level ATX and setext headings, with levels, paths and spans.
- [Text run length encode](/tools/text-run-length-encode): Run-length encode Unicode text into canonical count:HEX; records and return the encoded string.
- [Text sentences chunk](/tools/text-sentences-chunk): Pack whole UAX #29 sentences into chunks of at most max_size code points, UTF-16 units or UTF-8 bytes.
- [Text sentences split](/tools/text-sentences-split): Split text into sentences using the default Unicode UAX #29 sentence boundary rules (Unicode 17.0.0).
- [Text delimiter chunk](/tools/text-delimiter-chunk): Split text on an explicit literal delimiter (Python str.split rules, optional max_splits) with spans and line numbers.
