Skip to main content

CSS Text Wrap Generator

API reference

Generate CSS for text wrapping and overflow: white-space, word-break, overflow-wrap, hyphens and text-wrap, plus single-line ellipsis or multi-line clamp. Test long words and URLs in a resizable live preview, read a plain-English explanation and copy the CSS.

Input

Only used for the preview and HTML snippet. Add long words, URLs, extra spaces or line breaks to test.

How spaces and line breaks are handled, and whether lines wrap.

The usual fix for long URLs. Also known by its legacy name, word-wrap.

auto needs a lang attribute on the element; the HTML snippet sets lang="en".

balance evens out heading lines; pretty avoids a lone last word in paragraphs.

Narrow the box to see where lines break.

Output

Your wrapped text will appear here.

wrapping declarations
 
What this does
CSS
 
HTML
 
Was this helpful?

More ways to use this tool

REST API

curl -X POST https://api.iotools.cloud/v1/tool/css-text-wrap-generator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Long words like Pneumonoultramicroscopicsilicovo…",
    "whiteSpace": "normal",
    "wordBreak": "normal",
    "overflowWrap": "anywhere",
    "hyphens": "manual",
    "textWrap": "wrap",
    "overflow": "visible",
    "lineClamp": "2",
    "boxWidth": "240",
    "fontSize": "18",
    "textColor": "#1f2937",
    "bgColor": "#f8fafc"
  }'

Swap in your own key from your account. The tool's fields are the body — no wrapper.

Ask an AI agent

Use the IOTools `css-text-wrap-generator` tool (CSS Text Wrap Generator) on this input:

YOUR_INPUT_HERE

Paste this at any agent connected to the IOTools MCP server, then add your input.

Embed widget

<iframe
  src="https://iotools.cloud/embed/css-text-wrap-generator/"
  width="100%" height="520" frameborder="0" scrolling="no" loading="lazy"
  title="CSS Text Wrap Generator — iotools.cloud"
  sandbox="allow-scripts allow-forms allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox"
  allow="clipboard-write"
  style="width:100%;border:1px solid #e5e7eb;border-radius:12px;overflow:hidden"></iframe>
<script src="https://iotools.cloud/embed.js" async></script>

Drop this into your own page — free, no key required, just a link back.

Cost per API/MCP callFrom 5 credits
Need more credits?View pricing

Also available with

Guides

Long URLs that push past the edge of a card, file names that need an ellipsis, headings that end with one word alone on the last line: these are all text-wrapping problems. CSS splits the fix across several properties: white-space, word-break, overflow-wrap, hyphens, text-wrap and the overflow rules. This generator puts them in one place. You can try them on your own text in a box you can narrow, and it explains in plain English what each setting does.

How to use it

  1. Paste sample text. Include the awkward parts, like a long URL, a hash, extra spaces or line breaks.
  2. Choose white-space. This controls whether spaces and line breaks are kept and whether lines wrap at all.
  3. Set word-break and overflow-wrap. These decide whether, and how, a word that is too long gets split.
  4. Optionally turn on hyphens: auto or a modern text-wrap mode (balance or pretty).
  5. Pick an overflow mode. Choose visible, hidden, scrolling, a single-line ellipsis or a multi-line clamp.
  6. Change the box width to see exactly where lines break, then copy the CSS.

Common recipes

  • Stop long URLs breaking the layout: overflow-wrap: anywhere;. It breaks only the word that doesn't fit. Use anywhere rather than break-word inside flex items, grid cells and tables, because only anywhere lets the container shrink.
  • Truncate to one line with "…": white-space: nowrap; overflow: hidden; text-overflow: ellipsis;. The element also needs a width, or a min-width: 0 flex parent. In ellipsis mode the generator forces nowrap for you.
  • Show only the first N lines: display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;. Every current browser supports the prefixed form, so the generator emits it alongside the standard line-clamp.
  • Keep code-style spacing: use white-space: pre (never wraps) or pre-wrap (keeps spacing but still wraps).
  • Tidier headings: text-wrap: balance evens out the line lengths, and text-wrap: pretty keeps a lone word off the last line of a paragraph.

word-break vs overflow-wrap

word-break: break-all splits every word wherever the line ends, short ones included. overflow-wrap only steps in for a word that can't fit on a line of its own. For ordinary text with the occasional long URL, overflow-wrap is almost always the right choice. The old name word-wrap is an alias for overflow-wrap. word-break: break-word is deprecated, which is why it isn't offered.

For spacing between letters, words and lines, use the CSS Text Spacing Generator. For underlines and strikethroughs, see the CSS Text Decoration Generator.

Privacy

Everything runs in your browser. Your text and settings are never uploaded.

white-spaceword-breakoverflow-wrapword-wraptext-overflowellipsisline-clamphyphenstruncatetext-wrap balance

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.