Skip to tool

Python Word wrap Online

Wrap long text to width.

The output updates as you type. The tool processes input in your browser.

Worked example

Choose a column width for plain text. Display width can differ for emoji and East Asian wide characters.

Width
24
Break string
"\\n"
Cut long words
false
Sample input
This is a long line that should wrap for readability.
Sample output
This is a long line that\nshould wrap for\nreadability.

Using this operation in Python

The interactive result uses JavaScript. Python str stores Unicode text. Encode to bytes when an API expects UTF-8 or another byte representation.

Python reference