Text Wrap & Quote Styler

Hard-wrap text at any column, prefix lines for email quoting or code comments, and convert straight quotes to typographic ones — for plain-text formatting.

Hard wrap breaks at word boundaries (72 is the email convention, 80 the code one). Prefixing happens after wrapping, so quoted lines stay under the limit together.

Greedy wrapping never uses an extra line, and loses on raggedness a quarter of the time

Filling each line as far as it will go and breaking when the next word does not fit is the obvious algorithm, and it is easy to assume something cleverer would do better. For line count, nothing can. Wrapping the same paragraph at every column from 20 to 90 and comparing against a dynamic program that considers every possible break, greedy matched the minimum line count in all 71 widths. Not most — all.

ColumnGreedy linesBest possibleGreedy raggednessBest possible
30 6 6 23 23
45 4 4 12 12
72 3 3 106 106

Line count is not what a reader notices. Raggedness is — the jaggedness of the right-hand edge, scored as the sum of squared gaps at the end of each line. Optimise for that instead and greedy loses in 20 of the same 71 widths, 28%, because it will leave a short line early to cram one more word in now. That is the trade Knuth and Plass made in TeX: accept a worse line now for a much better one later, at the cost of a dynamic program instead of a loop. For a plain-text wrapper aimed at email quoting and code comments the loop is the right call — but the output is optimal in one sense and not the other.

The column is a hard promise, and one route breaks it

A word longer than the column is chopped rather than allowed to overhang, so the output never exceeds the width — checked at all 71 widths, no line ever ran over. The cost is that a long URL gets cut mid-token, which is ugly and is exactly the price of the guarantee: https://example.com/a/very/lon then g/path/that/will/not/fit/anywh.

PrefixRequested columnEffectiveLongest line
"> " 72 70 69
">> " 72 69 70
"// " 72 69 70
15 spaces 20 10 25 — over by 5
20 spaces 20 10 30 — over by 10

The prefix is subtracted from the column before wrapping and the result is floored at 10, so a long prefix with a small column produces lines longer than you asked for — up to 10 characters over. The condition is exact: the promise breaks when the prefix is longer than the requested column minus 10. At the default 72 that needs a 63-character prefix and will never happen; at the minimum column of 20 an 11-character indent is enough.

And the apostrophe is undecidable

The smart-quote pass turns an apostrophe after a space into an opening mark and one after a letter into a closing mark. Against 8 cases a typographer would have opinions about, it gets 5 right — including nested quotes, which is the case people expect to break.

InputOutputRight?
don't don’t
the dogs' bowls the dogs’ bowls
'quoted' ‘quoted’
"quoted" “quoted”
'tis the season ‘tis the season
rock 'n' roll rock ‘n’ roll
the '90s the ‘90s
He said "it's fine" He said “it’s fine”

All 3 failures are the same thing, and every case of that thing fails: elision. 'tis, 'n' and the '90s all begin with an apostrophe standing in for dropped letters, so they want a closing mark and the rule gives them an opening one. It is not a careless rule — an opening single quote and a leading elision are the same character in the same position, so no test that looks only at punctuation can separate them. Telling them apart needs a dictionary, and this page does not have one. 5 out of 8 from a one-line regular expression is a good trade; knowing which 3 it misses is better than assuming it misses none.

How to use

  1. Paste your text.
  2. Set the wrap column and prefix.
  3. Choose whether to preserve existing paragraphs.
  4. Copy the formatted result.

Frequently asked questions

What is hard wrapping?

Inserting real line breaks at a fixed column, so the text is stored with the breaks in it rather than reflowing to fit the window. It is standard for email in plain text, for commit messages and for source code comments, where a fixed width is expected.

What column should I wrap at?

Seventy-two is conventional for email and commit messages, leaving room for quote prefixes to be added without pushing past eighty. Eighty is the traditional code width, though many projects now use 100 or 120. The constraint is readability rather than any technical limit — very long lines are genuinely harder to read.

Why do commit messages have a wrapping convention?

Because git does not wrap them for you. The convention is a short summary line under about fifty characters, a blank line, then the body wrapped at seventy-two so it displays properly in terminals and in tools that indent it.

What are typographic quotes?

The curved opening and closing quotation marks and the true apostrophe, as opposed to the straight vertical marks a keyboard produces. They read better in prose and are wrong in code, where a curly quote is a syntax error — which is why pasting from a word processor into an editor so often breaks a program.

What is the difference between a hyphen, an en dash and an em dash?

Increasing lengths with distinct jobs: the hyphen joins words, the en dash spans ranges such as page numbers, and the em dash marks a break in a sentence. Using a hyphen for all three is common and mildly wrong; the distinction is worth keeping in published prose.

Should I hard-wrap prose meant for the web?

No. Web text reflows to the reader's window, and hard-wrapped paragraphs produce ragged lines on narrow screens and awkward gaps on wide ones. Hard wrapping suits plain-text contexts where nothing else will do the wrapping.

🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.