Skip to tool

JavaScript String.padStart() Online

Pad start of string.

The output updates as you type. The tool processes input in your browser.

Worked example

Fill is inserted before the original text. Zero padding is useful for fixed-width labels or identifiers.

Width
8
Fill
"0"
Sample input
42
Sample output
00000042

JavaScript example

console.log("42".padStart(8, "0"));
Expected native output
00000042

Using this operation in JavaScript

The interactive result uses JavaScript. JavaScript string indexes count UTF-16 code units. Use code-point iteration when working with supplementary Unicode characters.

JavaScript reference