Shortens a string when it is longer than a maximum length, then appends an omission marker (default "..."). Optional separator cuts at a word or pattern boundary. Part of Lodash String (stable since 4.0.0 — not deprecated). Note:options.length includes the omission string.
Pass the string and options shown below. Check the return type before you chain another helper.
Syntax
Call _.truncate. Start with this line.
Lodash
_.truncate([string=''], [options={}])
Call
What it does
_.truncate([string=''], [options={}])
Primary signature.
_.truncate(string)
Transform or inspect a string.
Prefer import truncate from "lodash/truncate" when you want a smaller bundle.
Library declarations
Lodash
_.truncate([string=''], [options={}])
Parameters
Parameter
Description
string
Optional. Value to truncate (default '')
options.length
Optional. Max result length (default 30, includes omission)
options.omission
Optional. Suffix when truncated (default '...')
options.separator
Optional. String or RegExp cut point before the limit
_.truncate is a Lodash String helper available since 4.0.0. It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.x
_.truncate()
Available in [email protected] full builds and the lodash/truncate modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.truncateSince 4.0.0
Bottom line: Safe for production once Lodash is on the page. Prefer import truncate from "lodash/truncate" for smaller builds. There is no single native truncate-with-options helper — CSS line-clamp is a display alternative.
Frequently Asked Questions
_.truncate([string=''], [options={}]) shortens a string longer than options.length and appends an omission (default '...'). Official default: 'hi-diddly-ho there, neighbo...'.
Yes. The maximum length counts the full result, including the omission string. With default length 30 and '...', the kept text is shorter than 30.
separator (string or RegExp) cuts at a natural break before the length limit — for example a space or /,? +/ — so you do not split mid-word when possible.
If string.length is less than or equal to length, _.truncate returns the string unchanged (no omission added).
Yes. Set options.omission — official example uses ' [...]'.
Use import truncate from "lodash/truncate" or require("lodash/truncate"). Full build: import _ from "lodash" then _.truncate.