Skip to content

Center Text

Center each line of text.

Text
Width
Output

No result

About Center Text

Center Text centres each line of a piece of text inside a fixed width by padding it with leading spaces. It is a layout shortcut for terminal output, plain-text documents, ASCII art and anywhere a monospaced font is used and a centred heading is wanted.

You set the width and the tool computes the padding per line - each line gets the floor of half the remaining width added to its left, so short lines sit centred in the field. The default of hello in a width of twenty gains seven leading spaces, since twenty minus five is fifteen and half of that is seven. The width is raised to a minimum of five, and a line longer than the width is left untouched rather than truncated.

Two edges are worth knowing. Because centering is done with plain spaces, it only looks centred in a monospaced font, and in a proportional font the result will drift. And an empty text still produces one line of half-width padding rather than an empty result, because the single empty line is padded like any other.

How to use Center Text

  1. 1 Paste the text you want centred.
  2. 2 Set the Width field to the total number of columns to centre within.
  3. 3 Run the tool to read each line padded with leading spaces.

Frequently asked questions

How is the padding calculated?

Each line receives the floor of half the remaining width as leading spaces, so a five-character line in a width of twenty gets seven spaces. The result sits centred, with any odd remainder on the right.

What happens to a line longer than the width?

It is left completely alone - not truncated, not wrapped and not centred. The tool only centres lines that already fit within the chosen width.

Will it look centred in any font?

Only in a monospaced font. The centering uses plain spaces, so in a proportional font the lines will not align precisely, and there is no option to use non-breaking spaces instead.

Why did an empty input still produce spaces?

An empty text is treated as one empty line, which is then padded with half the width in spaces. So an empty input returns a run of padding rather than nothing.

Free, online, and private

Free to use

Center Text is completely free. There is no account to create, no login, and no hidden charge or usage limit.

Runs online in your browser

It is a free online tool that runs entirely in your browser. Nothing to download or install — open the page and start using it right away.

Your data stays private

All processing happens locally on your device. Your input is never uploaded, stored, or tracked, so it never leaves your browser.

How Center Text behaves in detail

These are the specifics of this implementation — the exact ranges, defaults and fixed settings you are working with.

Parameter Value
Input a Text textarea starting with hello and world on two lines, and a Width number field starting at twenty
Output each line is left-padded with the floor of half the remaining width, so short lines sit centred in the field
Width clamp the width is raised to a minimum of five, so a smaller value is ignored
Long lines a line longer than the width is left untouched, not truncated and not wrapped
Default hello in a width of twenty gains seven leading spaces, since twenty minus five is fifteen and half is seven
Empty text an empty text still produces one line of half-width padding spaces rather than an empty result

Compiled from the implementation of this tool and checked against it by itoolnet.

What Center Text does not do

Knowing the edges of a tool saves more time than another list of its features. These are the cases where it will not do what you might expect.

  • Centering is done with leading spaces only, so it assumes a monospaced font. In a proportional font the result will not look truly centred, and there is no option to centre by word or to use non-breaking spaces.
  • A line longer than the width is left completely alone - it is not truncated, not wrapped and not centred, which means the tool only centres lines that already fit the chosen width.
  • An empty input returns a run of padding spaces rather than nothing, and the width has no upper bound, so a very large width produces a very long line of spaces with no guard.

Tested and documented by itoolnet, the team that builds and maintains this site.

Share & embed this tool

Writing a guide or article? You are welcome to link to Center Text with the snippet below. It is free, runs entirely in your browser, and needs no signup.