String Truncator

Shortens text to a maximum length, appending a suffix (like '...') only when the text was actually cut, leaving shorter text completely untouched. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-22

Overview

Introduction

Preview text, card titles, and notification snippets all need a maximum length with a visual cue that they were cut off.

This tool handles both the cutting and the suffix.

What Is String Truncator?

A truncation tool that cuts text to a maximum character length and appends a suffix only if truncation actually happened.

It runs entirely client-side as part of this site's String Tools collection, so nothing you paste is ever uploaded to a server.

How String Truncator Works

The tool checks whether the input's code-point length exceeds the maximum; if so, it slices to that length and appends the suffix, otherwise it returns the input unchanged.

The transformation happens synchronously in JavaScript the moment you type, with no network round trip involved.

When To Use String Truncator

Use it for generating preview snippets, card titles, or notification text with a consistent maximum length.

It's a fast way to get the answer without opening a code editor, a REPL, or writing a one-off script just to check.

Often used alongside String Slicer and Substring Extractor.

Features

Advantages

  • Only adds the suffix when truncation actually occurs, avoiding a misleading '...' on already-short text.
  • Operates on Unicode code points, not raw UTF-16 units.

Limitations

  • Truncates at a fixed character count, not at a word boundary, so it can cut mid-word.

Examples

Truncating a long sentence

Input

This is a fairly long sentence that needs truncating.

Output

This is a fairly lo...

The text is cut to 20 characters and '...' is appended since it was truncated.

Best Practices & Notes

Best Practices

  • For word-safe truncation, manually trim to the last space before the cut point if mid-word cuts look awkward.

Developer Notes

The check `chars.length <= maxLength` returns the input untouched before any slicing happens, which is what prevents the suffix from being appended to text that didn't actually need truncating.

String Truncator Use Cases

  • Generating a preview snippet with a consistent max length
  • Shortening a title for a card or list view
  • Truncating text for a notification with limited space

Common Mistakes

  • Expecting truncation to respect word boundaries; it cuts at an exact character count.

Tips

  • Set the max length to account for the suffix's own length if you need a strict total character budget.

References

Frequently Asked Questions