Wrap text at a fixed line width

Paste long lines and set a width; the tool inserts line breaks between words so that no line is longer than that width.

Live demo · real result from this tool

Result

Wrapping long lines makes plain text easier to read in emails, commit messages and terminals, where nothing reflows the text for you.

Processed on your device — nothing is uploaded.

How to use the Text Wrapper

  1. Paste your text into Your text.
  2. Set Line width in characters, anywhere from 5 to 500. The default is 40.
  3. Tick Split words longer than the width if long links or codes must not stick out past the edge.
  4. Copy the wrapped text.

What it does and when to use it

Most apps wrap text on screen automatically, but the line breaks are not saved. When text is going somewhere that does not reflow it, you need real line breaks at a fixed width. That is called hard wrapping. Use it for:

  • plain-text emails and mailing-list posts;
  • Git commit message bodies and code comments;
  • README files, text files and terminal output;
  • labels, receipts and other fixed-width printouts.

Hard wrapping also makes long lines readable in tools that do not wrap, such as some code editors and diff views.

The reverse job, joining hard-wrapped lines back into paragraphs, is done by the Text Unwrapper. If you only want one long line with no breaks at all, use Remove Line Breaks. To cut text to a maximum length instead of wrapping it, try the Text Truncator.

How it works

Each existing line is handled on its own. If it already fits within the width, it is kept unchanged. Otherwise the tool splits it into words at spaces and fills lines greedily: it keeps adding the next word plus one space while the line stays within the width, and starts a new line when the next word will not fit. The width is measured in visible characters, so emoji are not counted twice.

With the split option on, a word longer than the width is cut into chunks of exactly the width before wrapping continues. Without it, such a word sits on a line of its own and is allowed to be longer. Any indentation at the start of the original line is kept on the first wrapped line. It all runs in your browser.

Worked examples

Email at 30 columns. “Plain text emails often wrap at a fixed width so they read well in any mail program.” at width 30 becomes three lines: “Plain text emails often wrap” (28 characters), “at a fixed width so they read” (29) and “well in any mail program.” (25).

A long link, kept whole. “See https://example.com/a/very/long/path/to/a/page for details” at width 20 puts the link on its own line, 46 characters long, with “See” above and “for details” below.

A long link, split. The same text with the split option on cuts the link into https://example.com/, a/very/long/path/to/ and “a/page for details”. Note that a split link no longer works when clicked.

Limits and tips

  • Continuation lines of an indented paragraph start at the left edge; only the first line keeps the indent.
  • Runs of spaces inside a wrapped line become single spaces.

Frequently asked questions

What width should I use?
It depends on where the text goes. RFC 5322, the standard for email messages, recommends lines of no more than 78 characters, and many people use 72 for plain-text email and Git commit messages. Narrow widths such as 40 suit code comments in side-by-side views and small screens.
Does it ever break a word in half?
Only if you tick "Split words longer than the width", and then only words that cannot fit on a line by themselves, such as long links. Normal words always move to the next line whole.
What happens to lines that are already short?
They are left exactly as they are. Existing line breaks and blank lines are kept, so paragraphs stay separate.
Is width counted in characters or in screen space?
In characters. An emoji or an accented letter counts as one. In a proportional font, lines of equal character count can still look uneven; use a monospaced font to see straight edges.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close