EditSafely

Left-pad Text

Pad the left side of every line to a fixed length.

Runs on your device, nothing uploaded

Pad to length
0 pads to the longest line.
Pad with (first character)
Try:

0 chars · 0 lines

Output

Pad the left side of every line to a fixed length.

Type or paste above to see the result here.

Example: Zero-pad numbers to width 5

What you paste never leaves this tab

Left-pad Text is JavaScript that your browser has already downloaded, and it does the whole job on your own machine. On a normal site, the text you paste is sent to a server that can log it, cache it or keep it. Here it is read and transformed inside this tab and nowhere else.

  • No upload
  • No length limit
  • Works offline once loaded
  • Nothing stored or logged

How to use Left-pad Text

  1. 1. Paste the lines you want padded. Enter one value per line, such as a column of numbers or short codes that need to line up to a consistent width.
  2. 2. Set Pad to length. Pad to length starts on Longest line (0), which pads every line to match the longest one. Tap a chip or type a width to pad to a fixed size instead; lines already longer stay as they are and a note says how many.
  3. 3. Choose the Pad with character. Type the character to fill the gap with, using the first character you enter. A zero produces zero-padded numbers, while a space produces a right-aligned column.
  4. 4. Copy the padded output. Copy the aligned lines into a spreadsheet, fixed-width file, or wherever consistent-width values are required.

When to use Left-pad Text

Left-pad Text adds characters to the start of every line until it reaches a fixed width, which is exactly what number formatting, fixed-width file formats, and column alignment require. Instead of writing a padStart loop, paste the list and set the target width.

  • Zero-padding invoice numbers. Invoice IDs need to always show as five digits, like 00042 instead of 42, to match an existing numbering convention. Padding with a zero to length 5 formats the whole batch at once.
  • Aligning a column of prices in a plain-text report. A monospace report needs prices right-aligned within a fixed column width so decimal points line up visually. Padding with a space to the column width does it without a spreadsheet.
  • Building fixed-width records for a legacy import. An old batch-processing system expects every field to be exactly 8 characters wide, padded with zeros on the left. Left-padding each value to that width prepares the file for import.
  • Formatting time components with leading zeros. Minutes and seconds pulled from a calculation come out as single digits like 5 and need to display as 05. Padding to length 2 with a zero fixes every value in the list.

Examples

Zero-pad numbers to width 5

Input

7
42
1337

Output

00007
00042
01337

About the Left-pad Text tool

Left-pad Text runs as plain JavaScript in your browser tab, with no server behind it. Pad the left side of every line to a fixed length. Whatever you put in stays on your device from start to finish.

The tool is part of EditSafely's Text Tools section, 211 single-purpose utilities built around the same idea: open the page, get the result, keep your data to yourself.

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.

That local-first design has practical benefits beyond privacy. The tool keeps working on a flaky connection once the page has loaded, results are instant because nothing round-trips to a server, and it is safe to use with confidential material.

Frequently asked questions

Does Left-pad Text cost anything?

Yes, it is completely free. All 2,943 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; your device's memory is the ceiling. Up to 10 MB the result updates as you type, after a short pause that grows with the size. Above 10 MB a Run button appears so typing stays smooth, and files open up to 50 MB. A very long result shows its first 2,000 lines on screen, while Copy and Download always include all of it.

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.

Related tools

All Text Tools →