String Padding Tool

Pad any string to a target length using padStart (left), padEnd (right), or both sides at once.

Input

Padding direction

Result

Result will appear here

Summary

Pad any string to a target length using padStart (left), padEnd (right), or both sides at once.

How it works

  1. Enter the string you want to pad in the input field.
  2. Set the target total length (must be greater than the current string length).
  3. Choose a fill character — default is a space, but any character works.
  4. Select the padding direction: Left (padStart), Right (padEnd), or Both sides.
  5. The padded result appears instantly below along with the equivalent JavaScript snippet.

Use cases

  • Format numbers into fixed-width columns for logs or reports.
  • Left-pad order IDs or invoice numbers with leading zeros.
  • Right-pad labels to align them in a monospace table.
  • Generate padded test fixtures for unit tests.
  • Produce padded binary or hex strings for low-level data formatting.
  • Quickly verify what padStart() / padEnd() would return without opening a browser console.

Frequently Asked Questions

Last updated: 2026-06-11 · Reviewed by Nham Vu