Pad text to a fixed width — left, right or centred

Choose a width and the tool fills each line with spaces, zeros or any character you pick until it reaches that width, aligned left, right or in the centre.

Live demo · real result from this tool
Align text

Result

Name        Price       Quantity    

Processed on your device — nothing is uploaded.

How to use the Text Padder

  1. Paste your text into Your text, one value per line.
  2. Set Width in characters (1 to 1,000). The default is 12.
  3. Choose Align text: Left (pad right), Right (pad left) or Centre.
  4. Type a Pad character. A space is the default; 0, ., -, * and = are common choices.
  5. Copy the padded lines. The output uses a monospaced font so you can see the columns line up.

What it does and when to use it

Padding makes every line the same width. That matters wherever text is laid out by character position instead of by a table:

  • Leading zeros for invoice numbers, IDs and file names, so 7 sorts after 6 and not after 69 when sorted as text.
  • Fixed-width data files, where each field must take up an exact number of characters.
  • Plain-text tables and receipts, with labels padded on the right and amounts on the left so they line up.
  • Banners and headings in code comments or terminal output, such as ===MENU====.
  • Dot leaders in tables of contents and menus.

A useful pattern for a two-column plain-text table: pad the labels left-aligned in one run, pad the numbers right-aligned in another, then put them side by side.

If you want numbers in front of lines, Add Line Numbers has its own zero-padding option. To limit lines to a maximum length rather than fill them to a minimum, use the Text Truncator. For the same text on every line, see Add Prefix/Suffix.

How it works

Each line is measured in visible characters. The gap is the width minus that length. If the gap is zero or less, the line is unchanged. Otherwise:

  • Left adds the whole gap after the text;
  • Right adds it before the text;
  • Centre puts half the gap (rounded down) before and the rest after.

The gap is filled with the first character of your pad character. Lines are processed independently and joined in their original order. Nothing is sent from your browser.

Worked examples

Leading zeros. The lines 45, 312 and 7 at width 5, right-aligned with 0, become 00045, 00312 and 00007.

A heading banner. “MENU” at width 11, centred with =, gives ===MENU====. The gap of 7 splits as 3 before and 4 after.

Dot leaders. “Item” and “Qty” at width 8, left-aligned with a dot, become “Item….” and “Qty…..”, both 8 characters long, ready for a value after them.

Limits and tips

  • Empty lines are padded too: they become a full row of the pad character.
  • Tabs count as one character, but display wider. Convert them with Tab to Spaces before padding.

Frequently asked questions

What happens to a line that is already longer than the width?
It is left exactly as it is. The padder only adds characters; it never cuts. Use the Text Truncator first if long lines must also be shortened.
How do I add leading zeros to numbers?
Choose "Right (pad left)" and type 0 as the pad character. With width 5, 7 becomes 00007 and 312 becomes 00312.
Where does the extra character go when centring?
When the gap is an odd number, the extra character goes on the right. "MENU" centred in 11 gets 3 characters on the left and 4 on the right.
Can I pad with two characters, like "-="?
No. Only the first character you type is used, so "-=" pads with "-". The box accepts two characters so that an emoji, which can take two, fits.
Are accented letters and emoji measured correctly?
Yes. Width is counted in visible characters, so "Café" counts as 4 and an emoji as 1. In a font where emoji are wider than letters, columns may still look uneven on screen.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close