Add Line Breaks Every N Characters
Insert a line break every N characters — hard wrap regardless of word boundaries.
characters
About Add Line Breaks Every N Characters
This tool inserts a line break every N characters, splitting your input into fixed-length chunks. Unlike wrap-text, it doesn't respect word boundaries — a long word will be broken in the middle. Useful when you need strict column-width compliance (terminals, fixed-width data files).
When to use it
- Producing fixed-width records for a legacy data feed
- Splitting a long base64 or hex string for display
- Breaking up a URL or token into manageable chunks for a printed page
- Forcing a hard wrap on a string that has no spaces
How it works
The input is iterated as Unicode code points. After every N code points, a newline is inserted, then counting resumes. Existing newlines in the input are preserved and reset the counter.
Examples
abcdefghijklmnop N=5
abcde fghij klmno p
Frequently asked questions
- How is this different from wrap-text?
- Wrap-text respects word boundaries — it breaks at spaces near the target column. Add-line-breaks just counts characters, breaking anywhere.
- Are existing line breaks preserved?
- Yes. The counter resets at each existing newline, so each line is independently broken into N-character chunks.