What Is Center Text?
Add leading ASCII spaces to position text within a target width of 10 to 300 graphemes. Width is a count of text clusters, not pixels or terminal columns. This tool adds no right padding and cannot guarantee visual centering in every font.
How to Use Center Text
- Paste text or load Sample.
- Choose Standard Centering to trim nonblank lines, Preserve Formatting to keep their spacing, or Block Centering to shift the original block together.
- Enter a whole-number width from 10 to 300. Title Style uses Standard Centering and adds a line separator at each end.
- Check lines with padding and over-width lines, then Copy or Download TXT. Select the output if Copy fails.
How Center Text Works
Intl.Segmenter counts grapheme clusters with locale en. Standard, Preserve and Title add max(0, floor((width - length) / 2)) leading spaces to each nonblank line. Block uses the longest nonblank original line for one shared offset. Odd spare widths round down on the left.
Blank and whitespace-only lines stay unchanged and do not determine block width. CRLF, LF and lone CR separators in the input value stay distinct, including mixed endings. A final separator creates a final empty line. Title uses the first existing separator, or LF when none exists, for its two added boundaries. Browser input/clipboard behavior may normalize endings.
Center Text Example
At width 10, Standard changes Hi into four leading spaces followed by Hi. Preserve keeps the original surrounding spaces and adds three more spaces before the line. No mode truncates an over-width line.
| Mode | Before A | Before BC | Other change |
|---|---|---|---|
| Standard | 4 spaces | 4 spaces | Trims nonblank lines |
| Block | 4 spaces | 4 spaces | Keeps original block spacing |
| Preserve | 4 spaces | 4 spaces | Keeps original line spacing |
| Title | 4 spaces | 4 spaces | Adds one separator at both ends |
When to Use Center Text
Plain-text headings
Position a short ASCII heading for a fixed-width draft.
Block layouts
Move a short address or diagram together without trimming relative indentation.
Spacing comparisons
Compare trimming against preserving original leading and trailing whitespace.
Common Mistakes
A grapheme is not a display column. A tab counts as one grapheme here and is not expanded. CJK, emoji, combining marks, bidirectional text and proportional fonts can look uneven. Even a monospace font does not establish uniform width for every Unicode cluster. Review the destination rather than relying on this count.
Width cannot be blank, fractional or outside 10 to 300. Input is limited to 1,000,000 UTF-16 units and 20,000 lines; output cannot exceed 5,000,000 units. Invalid settings clear output and disable export. Over-width lines receive no padding; in Block mode one wide line can prevent padding for the whole block. Missing segmentation support shows an error.
Tips for Better Results
Start with ASCII text and a whitespace-preserving destination. Standard and Title trimming can alter meaningful code indentation; choose Block or Preserve for that task. Use Convert Tabs/Spaces separately if you need to replace literal tabs, and inspect its result before centering. A failed download leaves the selectable output available.
Share This Tool
Share this free text centering tool with designers and content creators!