String Padding Tool
Pad any string to a target length using padStart (left), padEnd (right), or both sides at once.
Use the String Padding Tool
Input
Padding direction
Result
Result will appear here
Visual breakdown
Padding
Original
JavaScript equivalent
Summary
String Padding Tool lets you pad any string to a target total length by prepending or appending a fill character of your choice. It mirrors JavaScript's built-in padStart() and padEnd() methods and is useful for formatting fixed-width columns, aligning numeric output, building test fixtures, and generating padded identifiers.
How it works
- Enter the string you want to pad in the input field.
- Set the target total length (must be greater than the current string length).
- Choose a fill character — default is a space, but any character works.
- Select the padding direction: Left (padStart), Right (padEnd), or Both sides.
- 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-05-23 · Reviewed by Nham Vu