Favorites

JavaScript String.prototype.padEnd() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
String.prototype.padEnd()
JavaScript String Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

The padEnd() method pads the end of a string with another string until it reaches a given length.

Description

The padEnd() method adds characters to the end of a string until it reaches the target length. If the string is already that long, it is returned unchanged. It's useful for lining up text in fixed-width output.

If the pad string is longer than needed, it's cut off to fit, and if it's empty, the original string is returned unchanged. Lengths are measured in UTF-16 code units, so strings containing emoji or wide characters may not line up exactly in a monospace display.

Padding is mainly useful in the console, plain-text files and fixed-width data formats. On web pages, alignment is better handled with CSS, such as a table or a grid layout, which adapts to fonts and screen sizes.

Syntax

string.padEnd(targetLength)
string.padEnd(targetLength, padString)

Parameters

  • targetLengthThe length of the resulting string.
  • padStringOptional. The text to pad with. Defaults to a space.

Return Value

The string padded at the end to the target length.

Example

console.log('abc'.padEnd(6, '.') + '|');
const rows = [['Tea', 3], ['Coffee', 4.5]];
rows.forEach(([item, price]) => console.log(item.padEnd(8) + '$' + price));

Browser Support

The following information will show you the current browser support for the String.prototype.padEnd() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee