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
Visual breakdown
Padding
Original
JavaScript equivalent
Summary
Pad any string to a target length using padStart (left), padEnd (right), or both sides at once.
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-06-11 ·
Reviewed by Nham Vu