Rule. For odd needs, right side gets the extra char.
Compatibility
Browser & Runtime Support
_.pad is a Lodash String helper available since 3.0.0. It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native padStart/padEnd (ES2017) cover one side each; Lodash _.pad remains the concise both-sides helper.
✓ Stable · Lodash 4.x
_.pad()
Available in [email protected] full builds and the lodash/pad 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
_.padSince 3.0.0
Bottom line: Safe for production once Lodash is on the page. Prefer import pad from "lodash/pad" for smaller builds. Ideal for centered fixed-width labels and console columns.
Frequently Asked Questions
_.pad([string=''], [length=0], [chars=' ']) pads string on both sides until it reaches length. Spaces are the default fill.
_.pad centers by padding left and right. _.padStart pads only the left; _.padEnd pads only the right.
If string.length >= length, the original string is returned unchanged. Official: _.pad('abc', 3) → 'abc'.
Yes. Pass chars like '_-'. Lodash repeats/truncates the fill to fit the needed pad width on each side.
There is no single native center-pad. You can combine String#padStart and String#padEnd, or keep using _.pad.
Use import pad from "lodash/pad" or require("lodash/pad"). Full build: import _ from "lodash" then _.pad.