Lodash _.padEnd() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
String

Definition

Pads string on the right until it reaches a target length. Part of Lodash String (since 4.0.0 — not deprecated). Padding characters are truncated if they exceed the needed width.

Pass the string and options shown below. Check the return type before you chain another helper.

Syntax

Call _.padEnd. Start with this line.

Lodash
_.padEnd([string=''], [length=0], [chars=' '])
CallWhat it does
_.padEnd([string=''], [length=0], [chars=' '])Primary signature.
_.padEnd(string)Transform or inspect a string.

Prefer import padEnd from "lodash/padEnd" when you want a smaller bundle.

Library declarations
Lodash
_.padEnd([string=''], [length=0], [chars=' '])

Parameters

ParameterDescription
stringOptional. Source string (default '')
lengthOptional. Target length (default 0)
charsOptional. Pad characters (default ' ')

Return Value

Return ValueDescription
*New padded string

Lodash Examples

Example 1 — Official: Pad with Spaces

Default fill character is a space.

Lodash
_.padEnd("abc", 6);
// → "abc   "
Try It Yourself

How It Works

  1. Length. "abc" is 3; target is 6.
  2. Need. 3 characters of padding on the right.
  3. Default. chars defaults to space.
  4. Docs. Matches the official first example.

Example 2 — Official: Custom Pad Characters

Multi-character pads repeat and truncate to fit.

Lodash
_.padEnd("abc", 6, "_-");
// → "abc_-_"
Try It Yourself

How It Works

  1. Need. Still 3 pad characters.
  2. Cycle. "_-" repeats as "_-_"…
  3. Truncate. Only the first 3 chars are used.
  4. Docs. Matches the official second example.

Example 3 — Official: Already Long Enough

No padding when length is not greater than the string.

Lodash
_.padEnd("abc", 3);
// → "abc"

_.padEnd("abc", 2);
// → "abc"  — not truncated
Try It Yourself

How It Works

  1. Compare. String length meets or exceeds the target.
  2. Skip. No pad characters are added.
  3. Same. Returns "abc" unchanged.
  4. Truncate? Use _.truncate if you need cutting.

Example 4 — Trailing Zeros

Useful for fixed-width fields and right-aligned fillers.

Lodash
_.padEnd("42", 5, "0");
// → "42000"

_.padEnd("Name", 10, ".");
// → "Name......"
Try It Yourself

How It Works

  1. Chars. Pass the fill you want on the right.
  2. Width. Target length is the full field width.
  3. Append. Fill is added after the original text.
  4. Use. Dot leaders, fixed columns, and padded codes.

Example 5 — padEnd vs padStart

Same length and chars; opposite sides.

Lodash
console.log(_.padEnd("abc", 6, "*"));   // "abc***"
console.log(_.padStart("abc", 6, "*")); // "***abc"
console.log(_.pad("abc", 6, "*"));      // "*abc**"
Try It Yourself

How It Works

  1. padEnd. Stars go on the right.
  2. padStart. Stars go on the left.
  3. pad. Splits fill across both sides.
  4. Pick. Match the side your layout needs.

Browser & Runtime Support

_.padEnd 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. Native String.prototype.padEnd (ES2017) covers the same idea in current engines.

✓ Stable · Lodash 4.x

_.padEnd()

Available in [email protected] full builds and the lodash/padEnd modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.padEnd Since 4.0.0

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import padEnd from "lodash/padEnd" for smaller builds. Use native padEnd in modern-only codebases if you prefer zero Lodash for this helper.

Frequently Asked Questions

_.padEnd([string=''], [length=0], [chars=' ']) pads string on the right until it reaches length. Official: _.padEnd('abc', 6) → 'abc '.
If string.length >= length, the original string is returned unchanged. Official: _.padEnd('abc', 3) → 'abc'.
Yes. Official: _.padEnd('abc', 6, '_-') → 'abc_-_'. Extra pad chars are truncated to fit the needed width.
padEnd adds on the right; padStart adds on the left. _.pad() pads both sides.
Yes. String.prototype.padEnd (ES2017) is similar. Lodash remains useful for older runtimes and Lodash pipelines.
Use import padEnd from "lodash/padEnd" or require("lodash/padEnd"). Full build: import _ from "lodash" then _.padEnd.

Next: _.padStart()

Pad a string on the left to a target length.

_.padStart() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful