TextToolboxTextToolbox

Center Text

Add leading spaces using grapheme counts. Choose Standard, Block, Preserve or Title mode, validate width from 10 to 300 and export TXT.

Built by Saurabh Kumar

Quick Answer

Center text by adding leading ASCII spaces within a width of 10 to 300 graphemes. Standard trims nonblank lines, Preserve keeps spacing, Block shifts them together and Title adds boundary separators. No right padding, truncation or universal visual-width guarantee.

Centering Mode

10 to 300. Adds leading spaces only.

CRLF, LF and CR separators in the input value are preserved. A final separator creates a final empty line. Browser paste and Copy may normalize endings.

Original Text

Centered Text

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

  1. Paste text or load Sample.
  2. Choose Standard Centering to trim nonblank lines, Preserve Formatting to keep their spacing, or Block Centering to shift the original block together.
  3. Enter a whole-number width from 10 to 300. Title Style uses Standard Centering and adds a line separator at each end.
  4. 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.

Input A followed by BC on a new line, width 10; spaces shown as counts
ModeBefore ABefore BCOther change
Standard4 spaces4 spacesTrims nonblank lines
Block4 spaces4 spacesKeeps original block spacing
Preserve4 spaces4 spacesKeeps original line spacing
Title4 spaces4 spacesAdds 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!