Wrap text to a fixed line width

Reflow long plain text to a chosen width without cutting ordinary words unless word breaking is enabled.

freeworks offlinenothing uploaded
ToolText Wrapper
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Each existing line is split into alternating whitespace and word runs, and a new line starts before adding the next word would exceed the selected width. Width is measured in Unicode code points from 10 to 200; it is not a byte or terminal-cell count. The 80-character default matches GNU fold and the convention inherited from the 80-column punched card introduced by IBM.

  • With word breaking disabled, an oversized URL or identifier remains intact even when it extends beyond the chosen width.
  • Paragraph preservation keeps existing newline boundaries; disabling it replaces newlines with spaces before reflowing the complete input.

Worked example

Wrap a long paragraph
Break a long paragraph into lines at the default 80-character width
Input
											The quick brown fox jumps over the lazy dog in the beautiful garden on a sunny afternoon. The birds were singing and the flowers were blooming all around the park.
										
Output
												The quick brown fox jumps over the lazy dog in the beautiful garden on a sunny
afternoon. The birds were singing and the flowers were blooming all around the
park.
											

When to use this

Git commit message bodies are commonly wrapped at about 72 characters, while RFC 5322 recommends no more than 78 characters for Internet message lines. GNU fold defaults to 80 columns, the same fixed-width convention used for source comments and README text.

Edge cases

  • A URL longer than the width has no whitespace breakpoint. Word breaking off leaves it intact and over width; word breaking on slices it at the selected number of code points.
  • A single newline remains a line boundary when paragraph preservation is on. With it off, that newline becomes a space before the combined text is wrapped.
  • The emoji 🦊 is stored as two UTF-16 code units but remains one code point, so word-breaking mode does not split its surrogate pair.
  • A tab or CJK character counts as one code point even when a terminal displays it across multiple columns, so visual line width can differ from the selected number.
  • The joined emoji 👨‍👦 contains several code points. Word-breaking mode may split that grapheme even though it appears as one symbol.

References