Text Wrap Formatter
Wrap or reflow text to a fixed line width.
关于此工具
Paste any text and reformat it to a desired line width between 40 and 120 characters. Choose from four wrap modes: hard wrap inserts real newlines, soft wrap previews wrapping without modifying the text, word wrap breaks only at word boundaries, and character wrap breaks at the exact column limit. A toggle lets you preserve existing paragraph breaks. The output shows line count and a one-click copy button.
使用方法
- 1 Paste your text into the input area.
- 2 Drag the line-width slider to your desired column limit.
- 3 Select a wrap mode: Hard Wrap, Soft Wrap, Word Wrap, or Character Wrap.
- 4 Toggle 'Preserve paragraphs' if needed.
- 5 Click 'Wrap Text' to see the result, then copy it with the Copy button.
What "wrapping" text really means
On screen, your editor wraps long lines automatically — but those breaks are cosmetic, vanishing the instant the window resizes. Many places need real line breaks baked into the text: fixed-width code comments, plain-text emails, README files, commit messages, terminal output, and any context where a monospaced column has a hard limit. This tool inserts those actual newline characters at a column width you choose, turning a single long paragraph into neatly bounded lines that stay wrapped wherever the text travels.
How word wrapping works, step by step
The core algorithm walks through your words one at a time, building up a line. It keeps adding the next word — plus a single space — as long as the result would still fit within your chosen width. The moment adding a word would overflow the limit, it ends the current line, starts a new one with that word, and continues. Because it only ever breaks between words, individual words are never split, so the output stays readable.
A worked example at width 20. Take the sentence The quick brown fox jumps (counting characters as it goes):
The quick brown foxis 19 characters — fits within 20.- Adding
jumpswould make 25 characters — too long, so the line ends. jumpsbegins the next line.
Result, two lines: The quick brown fox / jumps. Notice the first line is 19, not exactly 20 — word wrapping fills each line as much as it can without exceeding the limit, so lines come out at varying lengths just under your width.
The four modes
| Mode | What it does |
|---|---|
| Hard Wrap | Breaks at word boundaries and writes real newlines into the output you copy. |
| Soft Wrap | Also wraps at word boundaries to show how the text would lay out at the chosen width. |
| Word Wrap | The same word-boundary wrapping, named for clarity — never splits a word. |
| Char Wrap | Breaks at the exact column, even mid-word, so every line is precisely your width. |
Hard, Soft, and Word wrap all break only between words, which is what you want for prose. Char Wrap is the exception and the one to reach for when a line must never exceed a fixed width no matter what — fixed-field data formats, ASCII art, or splitting a long unbroken string. At width 10, the 12-character word antidisestablishmentarianism stays whole under word wrap but is sliced into antidisest, ablishment, and so on under char wrap.
What "preserve paragraphs" controls
Text structure usually relies on blank lines to separate paragraphs. With Preserve paragraphs on, those blank lines are left untouched, so a multi-paragraph document keeps its shape after wrapping. With it off, runs of three or more consecutive blank lines are collapsed down to a single blank line, tidying up text that arrived with excessive vertical spacing. Either way, wrapping happens line by line, so each existing paragraph is reflowed within itself rather than merged with its neighbors.
Practical tips
- 72 is the email and commit-message convention; 80 is the classic code width. Set the slider to match the destination — the range runs 40 to 120 characters.
- Use Char Wrap for anything that must align in columns. When you need every line guaranteed under the limit, word boundaries are a liability; char wrap is the safe choice.
- Check the line count. The output panel reports how many lines you produced — a quick sanity check that your width gave a reasonable shape.
- Re-wrap, don't hand-fix. If a wrapped block looks wrong, change the width or mode and wrap again rather than editing line breaks by hand.
Common mistakes
- Wrapping text that is already wrapped. Feeding in text that has old, narrower line breaks leaves those breaks in place — the tool reflows each existing line but won't undo prior wrapping. Join the lines first if you want a clean re-wrap.
- Expecting char wrap to keep words intact. It deliberately does not. If a sliced word looks wrong, you wanted word wrap.
- Wrapping code that depends on real long lines. URLs, long string literals, and some markup break if a newline lands inside them. Wrap prose and comments, not load-bearing code lines.
Is my text private?
Yes. All wrapping runs in your browser as you type — nothing is uploaded, logged, or stored on a server. You can paste sensitive drafts and the tool still works with your network disconnected.