TextToolboxTextToolbox

Pad Text to Length

Pad physical lines with a single grapheme on the left, right or both sides, with explicit truncation.

Built by Saurabh Kumar

Quick Answer

Pad lines to a target grapheme count using custom fill and left, right or center padding. Keep longer lines by default, or explicitly truncate them with an optional single ellipsis.

Keep original allows lines longer than the target. Center puts an odd extra pad on the right. Custom fill works with every padding side.

0 lines; 0 padding graphemes added; 0 original graphemes removed

What Is Pad Text to Length?

Add a chosen grapheme to the left, right or both sides of each physical line. A target is measured in graphemes, not UTF-16 units, bytes or visual columns. Long lines stay unchanged by default, so that setting does not guarantee every line has exactly the target length.

How to Use Pad Text to Length

Paste a line-based list. Choose padding side and a single padding grapheme, then enter a target from 1 to 1,000. Decide whether to keep, truncate or shorten long lines with one ellipsis. Check the output before Copy or Download TXT.

How Pad Text to Length Works

Intl.Segmenter identifies original grapheme boundaries. Missing length is filled on the selected side; Center puts the odd remainder on the right. Truncate keeps the first target graphemes. Ellipsis reserves one place for the single U+2026 character, including targets one and two. Padding that combines with neighboring text and changes the intended count is rejected rather than silently reporting a fixed length. Added padding and removed original graphemes are counted separately.

See Unicode text segmentation for the difference between grapheme boundaries and language-aware line breaking. Runtime Unicode versions may differ.

Pad Text to Length Example

With zero as the fill, the exact examples below show padding and truncation separately.

Exact settings and outcomes
Input and settingResult
Left, A, target 300A
Center, Hi, target 50Hi00
Ellipsis, abcd, target 1One ellipsis character
Keep, long, target 2long remains unchanged

When to Use Pad Text to Length

Plain-text lists

Align short labels with a chosen fill.

Identifier samples

Add leading zeros to already validated digit strings.

Length experiments

Compare keep and truncate before changing a file.

Common Mistakes

This does not parse numbers, CSV columns or fixed-byte records. Left zero-padding a negative or decimal string is ordinary text manipulation, not numeric formatting. Grapheme widths vary in fonts and terminals. A leading combining mark or joined fill may fail the boundary check; choose a standalone space or zero instead. CRLF, LF, CR and trailing empty records in the input value are retained, although browser inputs may normalize them.

Input is limited to 1,000,000 UTF-16 units and 20,000 physical lines. Output is limited to 5,000,000 units. Invalid settings clear output and disable export; these budgets are not a browser speed guarantee.

Tips for Better Results

Use Keep while drafting if cutting information would be risky. For truly fixed-length output, choose explicit truncation and retain the original. Use Center Text when only leading spaces for visual centering are needed.

Convert Tabs/Spaces and Center Text handle different spacing tasks.