Fluid Text to Fixed-Width Text Converter
Convert fluid text to fixed-width wrapped text and back. Custom line width, prefix support, paragraph preservation. Free online word wrapper.
About
Fixed-width text formatting is a requirement in commit messages (Git enforces 72 characters), code comments, plain-text emails (RFC 2822 recommends 78 characters), and terminal output. Manual line-breaking is error-prone: one misplaced break corrupts a paragraph when the text is later reflowed. This tool performs greedy line-filling against a configurable width W, optionally prepending each output line with a fixed string (e.g. // or # ). The prefix length is subtracted from W before wrapping, so content never exceeds the column limit. Paragraph boundaries, denoted by consecutive blank lines, are detected and preserved in both directions.
The unwrap (fixed β fluid) operation reverses the process: it strips the prefix from each line, joins lines within the same paragraph block into a single flowing string, and restores double-newline paragraph separators. Note: unwrapping assumes lines were originally wrapped by this algorithm or a compatible greedy wrapper. Text with intentional short lines (poetry, ASCII art) will be collapsed. Words longer than W β len(prefix) are placed on their own line without breaking, so the output may exceed the column limit for those tokens.
Formulas
The wrap algorithm uses greedy line-filling. Given a maximum line width W and a prefix string P, the effective content width per line is:
For each paragraph (block of text separated by double newlines), words w1, w2, β¦, wn are placed sequentially. A word wi fits on the current line if:
where the 1 accounts for the separating space (omitted for the first word on a line). If the word does not fit, the current line is flushed as P + lineContent, and a new line begins with wi. If a single word exceeds Weff, it occupies its own line (the line will exceed W; no mid-word hyphenation is applied).
The unwrap operation reverses this. Consecutive non-blank lines form a paragraph block. For each line, the prefix P is stripped from the start (if present). The remaining content is joined with single spaces. Paragraph blocks are separated by double newlines in the output.
Reference Data
| Context | Standard Width | Common Prefix | Source / Authority |
|---|---|---|---|
| Git commit body | 72 chars | (none) | Git project guidelines |
| Python docstrings (PEP 257) | 72 chars | (4 spaces) | PEP 257 |
| Linux kernel comments | 80 chars | * | kernel coding style |
| RFC 2822 email | 78 chars | > | IETF RFC 2822 Β§2.1.1 |
| USENET / plain text | 80 chars | (none) | Historical convention |
| Java / C / C++ block comment | 80 - 120 chars | * or // | Google style guides |
| Python PEP 8 | 79 chars | # | PEP 8 |
| Ruby style guide | 80 chars | # | rubystyle.guide |
| Rust (rustfmt default) | 100 chars | // | rustfmt.toml default |
| Go (gofmt) | No hard limit | // | Effective Go |
| Fortran fixed-form | 72 chars | C | Fortran 77 standard |
| COBOL Area A+B | 72 chars | (cols 1-6 reserved) | COBOL-85 standard |
| Terminal (standard) | 80 chars | (none) | VT100 / ANSI |
| Terminal (wide) | 120 chars | (none) | Modern default |
| LaTeX body text | 80 chars | % | Convention |
| Markdown prose | 80 chars | (none) | markdownlint MD013 |
| SQL line comments | 80 - 120 chars | -- | Convention |
| Shell scripts | 80 chars | # | Google shell style guide |