Left-pad a String
Pad the left side of every line to a fixed length. Runs entirely in your browser, so your data never leaves your device.
0 chars · 0 lines
Output
The result appears here as you type.
How to use Left-pad a String
- 1. Paste your lines. Enter the values you want padded into the input pane, one per line, such as a column of numbers of varying width.
- 2. Set the target length. Enter the final length each line should reach in Pad to length. Lines shorter than this get padded; lines already at or beyond it are left unchanged.
- 3. Choose the pad character. Type the character to repeat in Pad with (first character), such as 0 for zero-padded numbers or a space for simple column alignment.
- 4. Copy the padded result. Copy the fixed-width lines from the output pane into a report, a fixed-width file format, or anywhere consistent column widths matter.
When to use Left-pad a String
Left-pad a String adds a repeated character to the start of every line until it reaches a fixed length, most commonly zeros in front of numbers. Reach for it whenever a downstream system expects fixed-width values, like invoice numbers or sortable IDs.
- Zero-padding invoice numbers. Your invoicing system expects five-digit numbers like 00007 instead of 7. Pasting a column of raw numbers and padding to length 5 with 0 produces the exact format it needs.
- Aligning a numeric column for readability. A plain-text report lists values of different widths and they don't line up visually. Padding them all to the same length with spaces makes the column align.
- Matching a fixed-width file format. An old mainframe-style file format expects every field to be exactly a certain number of characters, padded on the left. This tool produces that fixed-width layout from variable-length values.
- Making IDs sort correctly as text. A list of IDs like 7, 42 and 1337 sorts incorrectly as plain text because 1337 comes before 7. Zero-padding them all to the same length fixes the sort order.
Examples
Zero-pad numbers to width 5
Input
7 42 1337
Output
00007 00042 01337
About the Left-pad a String tool
Left-pad a String does its work locally, right in the browser. Pad the left side of every line to a fixed length. There is no upload step, no queue and no account, and your data never travels over the network.
It belongs to the String Tools collection on EditSafely, a set of 159 small, focused String utilities that share the same instant, private workspace.
You can shape the output with 2 settings, including Pad to length and Pad with (first character), and the result refreshes the moment you change one. A worked example further down the page shows exactly what the tool produces for a real input.
Running locally also makes the tool fast and dependable: results appear as you type or drop a file, there is no server outage that can take it down mid-task, and confidential data can be processed without a second thought.
Frequently asked questions
Does Left-pad a String cost anything?
Yes, it is completely free. All 2,658 tools on EditSafely work without an account, a subscription or usage limits.
Is it safe to paste sensitive or confidential data?
No data leaves your device. The whole tool is JavaScript that runs inside your browser tab, so there is no upload, no server-side processing and no log of what you did. If you disconnect from the internet after the page loads, it keeps working.
How much text can I process at once?
There is no fixed limit. Because the work happens on your own device rather than on a shared server, the practical ceiling is your machine's memory, which comfortably handles inputs far larger than typical online tools allow.
Do I need to sign up or install anything?
Nothing to install and no account needed. Open the page in any up-to-date browser, including on a phone or tablet, and the tool is ready.
How do I use the result?
The output panel has a one-click copy button, and you can keep refining the input while you work; the result updates in place as you type.