Word Wrap Formatter

Greedy word wrap: break text into lines no wider than the limit, keeping words longer than the limit intact on their own lines.

Description

Wrap whitespace-delimited text greedily at a chosen character width.

Predictable word wrapping is useful for plain-text exports, console output, fixed-width previews, and testing line-length behavior.

When to use Word Wrap Formatter

  • Preview fixed-width plain text
  • Prepare console copy
  • Count lines produced by a width limit

How the calculation works

Words are appended while the separating space and word fit; otherwise a new line begins. A word longer than the width remains intact on its own line.

Interpreting the result

Original whitespace runs and line breaks normalize to single spaces. Width counts JavaScript code units, which can differ from rendered columns for emoji, combining marks, and wide glyphs.

Important limitations

  • Long words are not split or hyphenated.
  • The greedy algorithm does not balance line lengths or preserve layout.
Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies