Repeat a string n times and return the concatenated result. Part of Lodash String (stable — not deprecated). If n is less than 1, the result is an empty string.
Pass the string and options shown below. Check the return type before you chain another helper.
Syntax
Call _.repeat. Start with this line.
Lodash
_.repeat([string=''], [n=1])
Call
What it does
_.repeat([string=''], [n=1])
Primary signature.
_.repeat(string)
Transform or inspect a string.
Prefer import repeat from "lodash/repeat" when you want a smaller bundle.
_.repeat is a Lodash String helper available in 4.x. It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native String.prototype.repeat (ES2015) covers the same idea in current engines, with stricter error rules for invalid n.
✓ Stable · Lodash 4.x
_.repeat()
Available in [email protected] full builds and the lodash/repeat 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
_.repeatLodash 4.x
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import repeat from "lodash/repeat" for smaller builds. Use native repeat in modern-only code if you prefer zero Lodash for this helper.
Frequently Asked Questions
_.repeat([string=''], [n=1]) returns string repeated n times. Official: _.repeat('*', 3) → '***' and _.repeat('abc', 2) → 'abcabc'.
Official: _.repeat('abc', 0) → ''. Lodash also treats values less than 1 as producing an empty string.
No. Strings are immutable. It always returns a new string.
_.repeat builds a string by copying the whole source n times. _.padStart grows a string to a target length by adding fill characters on the left.
Yes. String.prototype.repeat (ES2015). Native repeat throws RangeError for negative n or Infinity; Lodash returns '' for n < 1.
Use import repeat from "lodash/repeat" or require("lodash/repeat") for tree-shaking. Full build: import _ from "lodash" then _.repeat.