Left Padder

Pads text on the left with a chosen character until it reaches a target length, the classic 'left-pad' operation used for zero-padded numbers, fixed-width IDs, and aligned columns. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-22

Overview

Introduction

Fixed-width identifiers, zero-padded invoice numbers, aligned numeric columns, all need text padded to a consistent length on the left.

This tool does that directly.

What Is Left Padder?

A left-padding tool built on JavaScript's String.prototype.padStart(), adding your chosen character to the front of the text until it reaches the target length.

It runs entirely client-side as part of this site's String Tools collection, so nothing you paste is ever uploaded to a server.

How Left Padder Works

The tool calls input.padStart(length, padChar); if the text is already at least that long, it's returned unchanged.

The transformation happens synchronously in JavaScript the moment you type, with no network round trip involved.

When To Use Left Padder

Use it for zero-padding numeric IDs, generating fixed-width fields for a legacy file format, or aligning short codes in a table.

It's a fast way to get the answer without opening a code editor, a REPL, or writing a one-off script just to check.

Often used alongside Right Padder and Center Aligner.

Features

Advantages

  • Simple, predictable behavior matching the native padStart() method exactly.
  • Never truncates; only ever adds padding.

Limitations

  • Pad character must be exactly one character.
  • Doesn't account for full-width or multi-byte characters when counting length.

Examples

Zero-padding a number

Input

7

Output

00007

With target length 5 and pad character '0', four zeros are added to the left.

Best Practices & Notes

Best Practices

  • Use Right-pad a String instead if you want padding added to the end.
  • Use Center a String if you want padding on both sides.

Developer Notes

This is a thin wrapper around the native String.prototype.padStart(length, padChar), which already handles the edge cases (target length shorter than input, pad character repetition) correctly per spec.

Left Padder Use Cases

  • Zero-padding invoice or order numbers to a fixed width
  • Generating fixed-width fields for a legacy flat-file format
  • Aligning short codes in a plain-text table

Common Mistakes

  • Supplying a multi-character pad string, which padStart() only partially repeats to fit.

Tips

  • Use '0' as the pad character for numeric IDs, or a space for text alignment.

References

Frequently Asked Questions