Text Centering

Center, left-align, or right-align text within a fixed width. Perfect for formatting CLI output, README banners, and plain text documents.

runs locally on your browser. Your data never leaves your device.

Alignment

Padding Character

(space)
0Input lines
0Longest line
0Output lines
80Width

Common Use Cases

Centre a title or section heading within an 80-column README or documentation file
Format CLI tool output or log messages with centred status banners framed by dashes or equals signs
Right-align line numbers or timestamps in a fixed-width report or table
Build decorative separators and boxes in a shell script's help text or deployment log output

About Text Centering

Plain text formatting, meaning centering, padding, and alignment within a fixed width, is an art that reaches back to the typewriter era. A 80-character-wide monospace line has been standard since the days of punch cards and terminal limitations. Today, fixed-width formatting is essential for command-line tools that produce framed or boxed output, for README files that need visual section breaks or banners, for ASCII art and diagram generation, and for any document that will be displayed in a monospace font where pixel-perfect alignment matters.

Centering requires integer arithmetic: given a line of length N that must fit within a width of W, the padding on the left should be floor((W - N) / 2), with any remainder pushed to the right. Left-alignment needs no padding; right-alignment puts all padding on the left. A 60-character heading centred in 80 columns gets (80 - 60) / 2 = 10 spaces on each side, resulting in perfect visual balance.

The choice of padding character, whether space (invisible), dash, star, equals, or something else, affects readability and visual hierarchy. Tools like 'figlet' and banner generators use this principle, building decorative borders with repeated characters. A README intro might use a line of equals signs as a section separator, while a CLI progress display might use spaces for alignment and dashes for visual structure.

Some workflows require consistent formatting of multi-line blocks: think of centring a title block in an email signature, formatting a usage menu in a help screen, or building a framed notice in a deploy log. This tool processes each line independently, applying the selected alignment and character to every line simultaneously, so you can paste a whole paragraph and see it formatted in context immediately.

Frequently Asked Questions

What is the default width and why?
80 characters is the historic standard width of a terminal or monospace text display, dating back to punch cards and early terminal standards. Most command-line tools, editors, and documentation targets assume 80-character wrapping. You can change it to any value: narrower for mobile viewing or wider for side-by-side panels.
How is centering calculated?
For a line of length L in a width of W, the left padding is (W - L) / 2 rounded down (floor division). If (W - L) is odd, the extra space goes on the right. This matches the visual centre and is used in typography and UI design. For example, a 10-character line in width 20 gets (20 - 10) / 2 = 5 padding on each side.
What happens if a line is longer than the width?
The line is output unchanged with no truncation. This prevents data loss. It is useful when examining a file with some lines exceeding your width, since you see the full content and can decide whether to widen the output area or re-wrap your source text.
Can I use multi-character padding?
No; the padding character is always a single character. You can use any printable character: space (invisible), dash, star, equals, underscore, etc. If you want a multi-character border (e.g. '=='), you would need to build that separately or use a dedicated ASCII art tool.
What is the longest line stat?
The 'longest line' shows the width of the widest line in your input (after trimming the newline but before any padding is applied). This is useful when you want to size your output width to fit your actual content: if the longest line is 60 characters and you set width to 70, you get symmetric padding.