Cadmeo

Number Padding

One per line. Lines already at or above the target length are left alone.

Padded

00007 00042 01250 00008

Number padding brings every line up to the same width by adding a character at the start or the end. Leading zeros are the usual case. They are what make identifiers sort correctly as text, since "0042" sorts before "0100" while "42" sorts after "100".

How it works

Each line is padded independently to the target length. Padding never truncates: a line already at or above the target passes through unchanged, so the output can be wider than requested if the input was.

  • Padding on the left produces leading zeros, which is what fixed-width identifiers and sortable filenames need.
  • Padding on the right produces fixed-width columns for plain-text alignment.
  • Any single character works, zero, space, hyphen, full stop for a dot leader.

The tool warns when a line already exceeds the target, because that is the case where the output is not uniform width and the reason a padded list still sorts wrongly.

Examples

Leading zeros for sortable identifiers

Values

7
42
1250
8

Length

5

Character

0

Result

00007
00042
01250
00008

All four now sort correctly as text. Unpadded, "1250" sorts before "42" because comparison is character by character.

A line that is already too long

Values

7
123456

Length

4

Result

0007
123456

The six-character line is left alone rather than truncated. Losing data silently would be worse than an uneven column.

Frequently asked questions

Why do leading zeros matter for sorting?

Because text sorts character by character. Without padding, "100" sorts before "42". The 1 comes before the 4. Padding to a fixed width makes text sorting match numeric order, which is why file naming conventions use 001, 002 rather than 1, 2.

What happens if a value is longer than the target length?

It is left exactly as it is. Padding only ever adds characters, so nothing is truncated. The tool flags this, because it means your output will not be uniform width.

Can I pad with something other than zero?

Yes, any single character. Spaces produce aligned plain-text columns, and full stops produce the dot leaders used in tables of contents.

Will spreadsheets keep the leading zeros?

Not by default, Excel and Google Sheets convert values that look numeric and drop the zeros. Format the column as text before pasting, or prefix each value with an apostrophe.