ForHosting KIT · Developer Utilities

Truncate Text to a Word Limit with an Ellipsis

Turn long text into a concise preview by choosing the maximum number of words to keep.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

The tool counts words, stops at the requested boundary, and adds an ellipsis only when the original contains additional words. Because it never cuts through a word, the result reads naturally in cards, search results, email previews, catalog listings, and editorial summaries. You can also choose a custom ending when three dots do not match your style guide. Processing is deterministic and happens without network access, so the same input and settings always produce the same output.

Choose a useful word limit

Start by deciding where the excerpt will appear and how much space that surface can comfortably hold. A compact card might need a very small word limit, while an article index or internal report can support a longer preview. Enter the source in the text field and put the number of words you want to retain in the words field. The limit counts whitespace-separated words rather than characters, so short and long words each count as one. This makes the setting easy to explain to editors and keeps limits consistent across entries with different vocabulary. If the source already contains no more than the chosen number, the complete normalized text is returned and no ellipsis is added. If more words exist, the tool keeps exactly the requested number and appends the selected ending. The result also reports the original and retained word counts, making it straightforward to confirm that the requested limit was applied before publishing or passing the excerpt into another workflow.

Understand whitespace and word boundaries

Words are recognized as runs of non-whitespace characters. Spaces, tabs, and line breaks separate them, and repeated whitespace does not create empty words. The output joins retained words with single spaces, which produces a clean one-line excerpt even when the source came from copied paragraphs, a spreadsheet cell, or text with inconsistent spacing. Punctuation remains attached to the word beside it, so commas, periods, apostrophes, and hyphens are preserved instead of being rewritten. This tool deliberately does not attempt linguistic tokenization or grammatical rewriting: it applies a transparent boundary rule that is predictable for API clients and browser users. The ellipsis is a suffix, not part of the retained word count. You may replace the default three dots with another short marker, including a single ellipsis character or an empty string. An empty suffix still truncates the excess words; it simply leaves no visible marker after the final retained word. Review unusually formatted text when punctuation conventions matter to your publication.

Use the result in repeatable workflows

For recurring work, keep the word limit and ellipsis consistent for every item in the same destination. That gives product grids, newsletters, knowledge bases, and search pages a steadier visual rhythm while preserving a clear rule for contributors. The returned truncated flag tells downstream code whether content was actually removed, so you can distinguish a generated excerpt from a source that already fit. The original_words and result_words values are useful for audits, tests, and content pipelines that need evidence of the transformation. The operation is deterministic: identical text, limit, and suffix settings yield identical output, with no model variation or network dependency. It is therefore suitable for build scripts and bulk processing where stable previews matter. The base request price is $0.002 when you use the hosted capability; the browser implementation follows the same core algorithm. Treat the excerpt as presentation text rather than an automatic summary, because truncation preserves the beginning of the source and does not identify which later facts may be important.

Article and blog cards

Create uniform teaser text for listing pages while ensuring every card ends after a complete word.

Product and catalog previews

Shorten long descriptions to a shared word budget for cleaner grids, feeds, and comparison screens.

Email and notification excerpts

Prepare predictable opening snippets for messages without cutting a name or ordinary word in the middle.

Is the ellipsis included in the word limit?

No. The limit controls how many source words are retained, and the ellipsis is appended afterward only when words are removed.

What happens when the text is already short enough?

The text is returned without an ellipsis, and the truncated field is false.

How are words counted?

A word is a run of non-whitespace characters. Spaces, tabs, and line breaks separate words, while repeated whitespace is treated as one separator.

Can I change or remove the ellipsis?

Yes. Supply a custom ellipsis of up to 32 characters, or use an empty string to remove the visible suffix.

Does this summarize or rewrite the source?

No. It keeps the first requested number of words in their original order and removes the remainder without interpreting the content.

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.

POSThttps://api.kit.forhosting.com/str/truncate-words

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.

curl -X POST https://api.kit.forhosting.com/str/truncate-words \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"The quick brown fox jumps over the lazy dog","words":5}'
{
  "text": "The quick brown fox jumps over the lazy dog",
  "words": 5
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "str.truncate_words",
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_chars100000
max_words10000
max_ellipsis_chars32
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →