↩️ Word Wrap Tool
By ToolNimba Text Team · Updated 2026-06-19
Paste text above to wrap it.
Some places will not soft-wrap your text for you: plain-text email, code comments, commit messages, README files, fixed-width terminals and printouts. This tool inserts real line breaks so every line stays within a width you choose, measured in characters. Paste your text, set the maximum width, and it greedily fits as many whole words on each line as will fit, breaking only at spaces so words are never split. Add an optional hanging indent if you want every wrapped line after the first to start a few spaces in.
What is the Word Wrap Tool?
Wrapping comes in two flavours: soft and hard. Soft wrapping is what a text editor or browser does on screen, the line visually folds to fit the window but the underlying text is still one long line with no break characters in it. Hard wrapping (what this tool does) inserts actual newline characters into the text, so the wrap is baked in and survives copying, pasting and viewing anywhere. You want a hard wrap whenever the destination will not wrap for you, or where you need lines to be a guaranteed maximum width.
The method here is a greedy line-fill. Reading words left to right, the tool keeps adding the next word to the current line as long as the word plus a single separating space still fits inside the chosen width. The moment a word would push the line over the limit, that word starts a fresh line. This is the same simple, fast approach used by classic Unix tools and by most word processors. It does not try to even out the ragged right edge the way a typesetting algorithm would, it simply packs each line as full as it can.
Two edge cases are worth knowing. First, a single word that is longer than the whole width (a long URL, for example) cannot be made to fit, so it is left intact on its own line and that line will exceed the width, the alternative would be to chop the word in half, which is rarely what you want. Second, the hanging indent is applied to every line of a paragraph except the first, which is the usual look for references, definitions and bulleted notes. The indent counts toward the width, so wrapped lines still respect the maximum.
When to use it
- Formatting plain-text email or forum posts so lines stay within a readable column.
- Wrapping long code comments or documentation to a project style limit such as 72, 80 or 100 columns.
- Reflowing a Git commit message body so it reads cleanly in logs and on hosting sites.
- Preparing fixed-width text for terminals, monospace printouts or legacy systems that do not soft-wrap.
How to use the Word Wrap Tool
- Paste or type the text you want to wrap into the input box.
- Set the maximum line width in characters (common choices are 72, 80 or 100).
- Optionally set a hanging indent so wrapped lines after the first are pushed in a few spaces.
- Choose whether to collapse runs of spaces and whether to keep blank lines as paragraph breaks.
- Read the wrapped result, check the width used, and copy it with the Copy button.
Formula & method
Worked examples
Wrap "The quick brown fox jumps" at a maximum width of 10 characters, no indent.
- Start line with "The" (length 3).
- Add "quick": 3 + 1 + 5 = 9, which is less than or equal to 10, so the line is now "The quick".
- Try "brown": 9 + 1 + 5 = 15, which is over 10, so push "The quick" and start a new line "brown".
- Add "fox": 5 + 1 + 3 = 9, fits, line becomes "brown fox".
- Try "jumps": 9 + 1 + 5 = 15, over 10, so push "brown fox" and start a new line "jumps".
- No more words, push the final line "jumps".
Result: Three lines: "The quick" (9) / "brown fox" (9) / "jumps" (5).
Wrap "alpha beta gamma delta" at width 12 with a hanging indent of 2 spaces.
- First line takes no indent: start with "alpha" (5).
- Add "beta": 5 + 1 + 4 = 10, fits, line is "alpha beta" (10).
- Try "gamma": 10 + 1 + 5 = 16, over 12, push "alpha beta" and start a new indented line " gamma" (7 characters including the 2 leading spaces).
- Try "delta": 7 + 1 + 5 = 13, over 12, push " gamma" and start a new indented line " delta" (7).
- No more words, push " delta".
Result: Three lines: "alpha beta" / " gamma" / " delta", every line within 12 characters.
Common line-width conventions and where they are used
| Width (chars) | Typical use |
|---|---|
| 72 | Git commit message body, plain-text email, many style guides |
| 79 to 80 | Python (PEP 8), classic terminals, COBOL/Fortran heritage, README files |
| 100 | Many modern code style guides for source files |
| 120 | Wide-screen code style limit used by some teams |
Soft wrap versus hard wrap
| Aspect | Soft wrap | Hard wrap |
|---|---|---|
| Where it happens | On screen, by the viewer | In the text, by line break characters |
| Survives copy/paste | No, text stays one long line | Yes, breaks are part of the text |
| Best for | Editing and reading on screen | Email, code comments, fixed-width output |
Common mistakes to avoid
- Expecting long words to be split. A greedy word wrap breaks only at spaces, so a single token longer than the width (a long URL or file path) is left whole on its own line and will overflow. If you truly need that broken, insert a space or a soft break yourself first.
- Forgetting the indent counts toward the width. A hanging indent eats into the available room. With width 40 and an indent of 8, wrapped lines have only 32 characters left for words. Set the width to the final line length you want, not the content length.
- Counting characters instead of display columns. Width here is measured in characters. Tabs and full-width or combining characters can occupy a different number of visual columns, so the on-screen width may differ from the character count in those cases.
- Hard-wrapping text that will be re-wrapped later. If the destination soft-wraps anyway, baking in hard breaks can leave odd short lines after edits. Hard wrap only when the target genuinely will not wrap for you.
Glossary
- Hard wrap
- Inserting real newline characters so the line breaks are part of the text and survive copying.
- Soft wrap
- A purely visual fold done by the viewer; the underlying text remains one continuous line.
- Greedy wrap
- A line-filling method that puts as many whole words on each line as will fit before moving to the next line.
- Line width
- The maximum number of characters allowed on a single line, measured here in characters.
- Hanging indent
- Leading spaces added to every line of a paragraph except the first, so continuation lines are pushed in.
Frequently asked questions
What is the difference between hard wrap and soft wrap?
A soft wrap is done on screen by your editor or browser; the text itself stays a single long line with no break characters. A hard wrap inserts actual newline characters, so the breaks become part of the text and survive copying, pasting and viewing in plain-text contexts. This tool produces a hard wrap.
Will it ever split a word in the middle?
No. The tool breaks only at spaces, so words stay whole. If a single word is longer than the chosen width (for example a long URL), it is placed on its own line and that line will exceed the width, because the alternative would be to cut the word in two.
What line width should I use?
It depends on the destination. 72 characters is common for plain-text email and Git commit bodies, 79 to 80 is the classic terminal and Python convention, and many code style guides use 100. When in doubt, 72 or 80 is a safe, widely readable choice.
What does the hanging indent do?
It adds leading spaces to every line of a paragraph after the first, which is the usual look for references, definitions and notes. The indent counts toward the width, so wrapped lines still stay within the maximum you set.
Does my text get uploaded anywhere?
No. All wrapping happens in your browser with vanilla JavaScript. Your text never leaves the page and nothing is sent to a server, so it is safe to use with private or sensitive content.
How are blank lines and extra spaces handled?
By default runs of spaces are collapsed to one and blank lines are kept as paragraph breaks, so paragraphs wrap independently. You can turn off space collapsing to preserve spacing, or turn off keeping blank lines to remove the empty separators from the output.