Text padding
Pad every line to a target width measured in Unicode code points — left, right or centre aligned, with a multi-character pad string that repeats as needed and optional truncation of over-long lines, plus counts for padded, untouched and truncated lines and total characters added.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Padded text
Width is counted in Unicode code points.
Paste text to pad it to a width
Lines: 0 · Padded: 0 · Kept as-is: 0 · Truncated: 0 · Code points added: 0
What this tool does
- Align fixed-width text so every column in a log excerpt, ASCII table or code comment starts at the same position.
- Pad fixed-length fields (bank messages, serial protocols, legacy forms) to an exact width with spaces or zeros.
- Produce monospaced blocks that line up when pasted into a code block or a chat window.
Example
Input
name age city
Output
name
age
cityWidth is counted in code points; the example right-aligns all three lines to 10, and a pad string of “.” fills with dots instead of spaces.
Frequently asked questions
Is padding measured in code points or bytes?
Code points (`[...line].length`). One Chinese character counts as 1 code point rather than 3 UTF-8 bytes, and one emoji counts as 1 rather than 2 UTF-16 units, so mixed CJK and emoji widths behave as you would expect.
Why is mixed CJK and Latin text still not visually aligned?
Because in a monospaced font a CJK glyph is usually twice as wide as a Latin one. Padding by code point guarantees an equal number of characters; true visual alignment needs East Asian Width calculations, which this tool does not do.
Can the pad string be more than one character?
Yes. With “-=” and five code points missing you get -=-=-, i.e. the pad string repeats as needed so the pattern is never broken.
What happens to lines longer than the target width?
They are kept as-is by default — no truncation, no error. Turn on “Truncate over-long lines” for strict fixed-width output; it slices by code point so multi-byte characters are never cut in half.
Keywords:文本填充行填充对齐text padding定宽补齐长度右对齐居中码点