# The String padEnd() method

> Learn how the JavaScript padEnd() method adds characters to the end of a string until it reaches a target length, using a space or a pad string you provide.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2019-02-25 | Topics: [JavaScript](https://flaviocopes.com/tags/js/) | Canonical: https://flaviocopes.com/javascript-string-padend/

The purpose of string padding is to **add characters to a string**, so it **reaches a specific length**.

`padEnd()`, introduced in ES2017, adds such characters at the end of the string.

```js
padEnd(targetLength [, padString])
```

Sample usage:

| padEnd()                  |              |
| ------------------------- |:-------------|
| 'test'.padEnd(4)          | 'test'       |
| 'test'.padEnd(5)          | 'test&nbsp;'      |
| 'test'.padEnd(8)          | 'test&nbsp;&nbsp;&nbsp;&nbsp;'   |
| 'test'.padEnd(8, 'abcd')  | 'testabcd'   |

Also see [`padStart()`](https://flaviocopes.com/javascript-string-padstart/).
