User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times
Enter integers separated by line breaks. Signs and leading zeros are preserved.
Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

About

Columnar data becomes unreadable the moment integers of varying digit counts sit flush-left or flush-right in a fixed-width field. A 7-digit value next to a 2-digit value creates visual noise that slows pattern recognition in log files, console output, and monospaced reports. This tool centers each integer within a uniform field width W, distributing padding characters symmetrically around the digits. The field width defaults to the longest integer in the batch, or you can lock it manually. Negative signs are preserved as part of the digit string before centering. The tool handles edge cases: empty lines are passed through unchanged, non-integer lines are flagged, and a width smaller than the longest integer triggers a warning rather than silent truncation.

Centering is defined by left-pad length L = floor((W โˆ’ D) รท 2) where D is the character length of the integer including its sign. The remaining padding fills the right side. This left-bias convention matches most typographic centering standards. Pro tip: when pasting into HTML or Markdown tables, use a non-breaking space ( ) as your pad character to prevent whitespace collapse.

center integers text alignment number formatting pad numbers center align numbers fixed width integers text formatting tool

Formulas

Each integer string of character length D (including sign) is centered within a field of width W. The total padding needed is P = W โˆ’ D. This padding is split into left and right portions:

L = floor(W โˆ’ D2)
R = W โˆ’ D โˆ’ L
result = repeat(c, L) + integer + repeat(c, R)

Where W = field width (auto-detected as max(D1, D2, โ€ฆ, Dn) or manually set), D = character length of the integer string, L = left padding count, R = right padding count, c = padding character (space, zero, dot, or custom). When W โˆ’ D is odd, the extra character goes to the right side (left-bias centering). If D โ‰ฅ W, the integer is output unchanged with no padding.

Reference Data

Input IntegerDigit Length (D)Field Width (W)Left Pad (L)Right Pad (R)Centered Output (pad = ยท)
51733ยทยทยท5ยทยทยท
422723ยทยท42ยทยทยท
-82723ยทยท-8ยทยทยท
1003722ยทยท100ยทยท
-10245711ยท-1024ยท
01733ยทยทยท0ยทยทยท
999999977009999999
-321044ยทยทยทยท-3ยทยทยทยท
25631034ยทยทยท256ยทยทยทยท
1234551023ยทยท12345ยทยทยท
-993511ยท-99ยท
711007
+423722ยทยท+42ยทยท
000075922ยทยท00007ยทยท
-00012371122ยทยท-000123ยทยท

Frequently Asked Questions

The minus sign is treated as part of the integer's character string. A value of -42 has a digit length D = 3, not 2. The sign is never separated from the digits. This means -42 and 100 occupy the same field space and center identically within a width of 7.
The tool displays a warning and outputs the integer unchanged (no truncation). Data integrity takes priority over formatting. If auto-width mode is active, this situation cannot occur because W is always set to max(D1 โ€ฆ Dn).
Yes. The tool treats each line as a raw string for length calculation. An input of 007 has D = 3, not 1. Leading zeros are never stripped. This is intentional for formatting IDs, codes, or zero-padded sequences.
When the total padding P = W โˆ’ D is odd, perfect symmetry is impossible. The tool uses left-bias centering: L = floor(P รท 2), placing the extra character on the right. This matches the convention used by Python's str.center() and most typographic systems.
Only single characters are supported as pad units. Using a multi-character string would make the field width ambiguous (visual width versus character count). If you need a repeating pattern like .ยท, pre-process the output by replacing single-character pads with your pattern externally.
Blank lines are preserved as empty lines in the output to maintain line correspondence. Non-integer lines (containing letters, symbols, or decimal points) are flagged with a warning marker in the output and passed through without padding. This ensures you can identify problematic lines without losing your place in the data.