DevTools Logo

Text Truncator

Text Truncator

Cut text to an exact character, word, or UTF-8 byte limit without splitting emoji or accents.

Runs in your browser
Try an example

Text to truncate

Truncated text

Type text to truncate it

Results update as you type. Nothing leaves your browser.

Details

Choose a limit unit (graphemes, words, or UTF-8 bytes), a cut direction, and how the ellipsis should behave. The tool slices the original text at safe boundaries: graphemes are counted with Intl.Segmenter, word cuts land between words, and byte cuts never split a multi-byte character or surrogate pair. Optional word-boundary snapping backs up to the nearest whitespace in the last quarter of the window. Before/after counts show characters, words, bytes and lines, and warnings explain every change. Everything runs locally in your browser.

More examples

Fit a meta description to 155 characters

Input: Discover handcrafted coffee beans, roasted in small batches and delivered fresh to your door every week.
Unit: characters · Limit: 155 · Ellipsis: … (counted) · Snap to word boundary: on
Output: Discover handcrafted coffee beans, roasted in small batches and delivered fresh to your door every week.

Text that already fits is returned unchanged; no ellipsis is added.

Cut a card title without splitting a word

Input: The quick brown fox jumps over the lazy dog
Unit: characters · Limit: 12 · Ellipsis: … (counted) · Snap to word boundary: on
Output: The quick…

The hard cut would split 'brown', so the cut moves back to the nearest whitespace in the last quarter of the window.

Fit an emoji-heavy string into a byte budget

Input: Café ☕ 😀
Unit: bytes · Limit: 8 · Ellipsis: … (counted)
Output: Café…

The ellipsis uses 3 of the 8 bytes; 'é' is 2 bytes and the 4-byte emoji is never split.

    Examples

    Snap a cut back to a word boundary

    Input
    The quick brown fox jumps over the lazy dog
    Characters: 12 · ellipsis: … (counted) · word boundary: on
    Output
    The quick…

    The hard limit falls inside 'brown'; snapping back to whitespace leaves 10 characters including the ellipsis.

    Byte budget with emoji and accents

    Input
    Café ☕ 😀
    Bytes: 8 · ellipsis: … (counted)
    Output
    Café…

    The ellipsis costs 3 bytes, 'é' costs 2, and the 4-byte emoji is dropped whole rather than split.

    Word limit with the tail kept

    Input
    one two three four five
    Words: 2 · count from: end · ellipsis: …
    Output
    …four five

    Word mode slices at the original whitespace boundaries; no words or spacing are rewritten.

    Use cases

    Fit search previews

    Trim meta descriptions and title tags to conventional character limits before pasting them into a CMS.

    Size strings for database columns

    Use byte mode for byte-limited columns and check that a multi-byte character will not be cut in half.

    Clamp UI labels

    Shorten card titles and navigation labels to a fixed grapheme budget without producing broken emoji.

    Prepare batch lists

    Turn on per-line mode to apply the same limit to every meta description candidate in a pasted list.

    Common mistakes

    Mistake:Using JavaScript slice() on emoji or accented text

    Fix:slice() counts UTF-16 code units and can split a surrogate pair; grapheme mode counts whole visible characters.

    Mistake:Assuming characters and bytes are the same

    Fix:'é' is one grapheme but two UTF-8 bytes, and emoji are usually four bytes. Compare both counts in the stats line.

    Mistake:Forgetting to account for the ellipsis

    Fix:Leave 'count ellipsis toward limit' on when a field has a hard cap, or turn it off to keep exactly N characters of content.

    Frequently asked questions

    Do characters and bytes count differently?

    Yes. A character in this tool is a grapheme — what a reader sees as one symbol. UTF-8 stores ASCII letters in one byte, accented letters such as é in two, and most emoji in four. If a database column or API documents a byte limit, choose Bytes; if it documents a character count, choose Characters. The stats line shows both counts so you can spot the difference before you paste.

    Will it split an emoji or an accented character?

    No. Character mode uses Intl.Segmenter when available, so flags, skin-tone emoji and decomposed accents such as e + U+0301 stay together. Byte mode walks graphemes with a byte prefix array and rounds the cut down to the largest whole grapheme that fits; a warning tells you how many bytes the cut moved back.

    Does the ellipsis count toward the limit?

    When 'Count ellipsis toward limit' is on, the ellipsis is subtracted from the budget first (… is one character and three UTF-8 bytes), so the output never exceeds the limit. Turn it off to keep exactly the requested amount of source text and add the suffix outside the count; a warning then notes that the result is longer than the limit. In word mode an ellipsis is not a word and never consumes the word budget.

    How does the word-boundary option work?

    After computing a hard character or byte cut, the tool scans the last quarter of the kept window for whitespace. If it finds a space, tab or line break, it cuts there instead and reports how many characters were given up. If the window contains no whitespace — a long URL or an unbroken identifier, for example — the hard cut stands. Word mode is always word-aligned, so the option has no effect there.

    Does my text leave my browser?

    No. Truncation runs entirely in your browser with pure client-side logic. Nothing is uploaded, sent to a server, or logged, so it is safe to use on draft copy and internal product names.

    References & standards