Word wrap text to width
Set a width of 32 and a long two-paragraph note reflows into 8 lines that fit the width, with the blank line between paragraphs kept. A word longer than the width stays whole on its own line. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Width
- 32
- Line count
- 8
- Paragraph count
- 2
Word wrap turns long, uneven text into readable lines that fit a chosen column width. Supply plain text and an integer width, and the tool reflows every paragraph while keeping words intact. Blank lines continue to separate paragraphs, so a multi-paragraph email or note keeps its structure. The result is deterministic and ready to paste into terminal output, source-code comments, plain-text documentation, issue trackers, or messages where predictable line lengths matter.
How wrapping to a column width works
Word wrapping solves a layout problem without rewriting the content. The tool reads the words in each paragraph from left to right and adds the next word to the current line when the word, its separating space, and the existing line fit within width. When they do not fit, it starts a new line before that word.
This means ordinary lines do not exceed the requested width and words are never cut in the middle. A single word that is itself wider than the limit is the deliberate exception: it remains whole on its own line because breaking an identifier, URL, filename, or technical token could change its meaning or make it impossible to copy. Whitespace inside a paragraph is normalized, so repeated spaces, tabs, and existing single line breaks become normal word separators.
Blank lines still identify separate paragraphs and the output retains a single blank line between them. This approach makes the tool useful both for unformatted prose and for reflowing text that was previously wrapped at the wrong width. It does not add hyphens, justify margins, detect Markdown, or paraphrase sentences.
The operation changes line placement only, making the output easy to inspect and repeat.
Choosing a useful width and reading the result
Choose width according to the destination rather than the size of the source text. Terminal logs and traditional email often benefit from moderately narrow lines, while code comments may need room for indentation and comment markers that you will add later. If the surrounding format consumes characters, subtract that prefix from the available column count before wrapping.
For example, a documentation system with a four-character comment prefix needs a text width four columns smaller than the final visual target. Empty source text is valid and returns no lines or paragraphs. Newlines are normalized to LF, making the same request stable across Windows, macOS, Linux, browsers, and edge execution.
Remember that width counts JavaScript string characters rather than rendered pixels. Proportional fonts give different visual widths to narrow and wide letters, so use this tool for column-oriented plain text, not pixel-perfect graphic layout. For fixed-width fonts, the character limit maps naturally to visible columns for most common text.
Reliable use in email, comments, and automation
For email drafts, wrap after composing and editing, because inserting words into already wrapped text can leave ragged short lines. Preserve intentional paragraph changes with blank lines, then pass the complete body in one request. For source comments, wrap the prose first and add language-specific prefixes afterward, or reduce width by the prefix length and attach the prefix to each returned line.
For terminal output, account for timestamps, log levels, indentation, and ANSI decoration outside this tool so the visible message stays within the desired boundary. In automated pipelines, store width as a project setting rather than scattering different values through scripts; this makes formatting changes reviewable and keeps generated files consistent. Test long technical tokens explicitly.
The algorithm never breaks a word, so a URL or generated identifier can exceed width, and callers that require hard limits should combine wrapping with a separate, explicit token-breaking policy. The capability performs no network calls and does not inspect the meaning of the text. Invalid requests are rejected before a result is produced.
What you can do with it
Prepare plain-text email
Reflow long draft paragraphs to a consistent column width while retaining blank lines between topics.
Format source-code comments
Create predictable prose lines before adding comment markers and indentation in a documentation workflow.
Keep terminal output readable
Wrap help messages, release notes, and console descriptions so they fit a chosen terminal column budget.
FAQ
Does the wrapper split long words?
No. Breaks occur only between words. A word longer than width remains whole on its own line and can therefore exceed the requested width.
What happens to existing line breaks?
Single line breaks inside a paragraph become spaces during reflow. One or more blank lines separate paragraphs and become one blank line in the result.
Does width measure pixels or characters?
It measures JavaScript string characters, not rendered pixels. It is best suited to plain text and fixed-width display contexts.
What width should I choose?
Pick it for the destination, not the source. If the lines will get a prefix, such as a four-character comment marker, subtract that prefix first so the finished lines still fit.
Does it add hyphens or justify the text?
No. Only the place where each line breaks changes. There are no hyphens, no stretched spacing and no rewording, so the words and their order stay exactly as you wrote them.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/str/word-wrap \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"Word wrapping keeps paragraphs readable in email, source comments, and terminal output without splitting ordinary words.","width":32}'const res = await fetch("https://api.kit.forhosting.com/str/word-wrap", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"text": "Word wrapping keeps paragraphs readable in email, source comments, and terminal output without splitting ordinary words.",
"width": 32
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/str/word-wrap",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"text": "Word wrapping keeps paragraphs readable in email, source comments, and terminal output without splitting ordinary words.",
"width": 32
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/str/word-wrap", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"text":"Word wrapping keeps paragraphs readable in email, source comments, and terminal output without splitting ordinary words.","width":32}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"text":"Word wrapping keeps paragraphs readable in email, source comments, and terminal output without splitting ordinary words.","width":32}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/str/word-wrap", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"text": "Word wrapping keeps paragraphs readable in email, source comments, and terminal output without splitting ordinary words.",
"width": 32
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "str.word_wrap",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_chars | 200000 |
max_width | 10000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Choosing a useful width and reading the result
The request accepts an integer from one through ten thousand and rejects missing, fractional, zero, negative, or excessive values with an invalid_input error. Successful output includes text as the primary copyable value, width as the applied constraint, line_count including blank separator lines, and paragraph_count for nonempty paragraphs.
Reliable use in email, comments, and automation
API calls use $0.002 per successful item, while the browser version runs locally for quick interactive formatting.
Technical questions
Can I wrap empty text?
Yes. Empty text returns an empty result with line_count and paragraph_count both set to zero, provided width is valid.
How much does the API call cost?
Each successful API request costs $0.002 per item. The browser tool runs locally and is free to use interactively.