Search Results

    Center Text

    Align text to the center of each line

    1


    Share

    What Is the Center Text Tool?

    The Center Text tool pads each line of your text with spaces on the left so that the content sits in the middle of a fixed-width column. You set how wide you want each line to be in characters, click Center Text, and the tool does the spacing math for every line at once. It is mainly used for plain-text environments where CSS or word processor alignment is not an option, like terminal output, README files, code comments, or printed monospace documents.

    It is a narrow use case, but when you need it, doing the padding by hand per line is genuinely tedious. That is what this is for.

    How to Use This Tool

    1. Paste or type your text into the input box above.
    2. Set the Line Width to the total number of characters you want each line to be wide. The default is 60. Your text will be centered within that width using leading spaces.
    3. Click Center Text and the tool reformats every line with the correct amount of left-side padding to position it in the middle.
    4. Copy the result using the Copy button, or select and copy manually. Use Clear to reset the input if needed.

    When Would You Use This?

    Formatting a plain-text title, heading, or label to sit visually centered in a fixed-width terminal window, console output, or monospace display.

    Preparing centered text for a README file, a plain-text banner, or an ASCII art header where normal text alignment tools are not available.

    Centering lines in a code comment block, a script output message, or any situation where you are working inside a fixed character-width constraint and want something to look balanced without counting spaces manually.

    Examples

    Centering a single heading line

    Input   : Hello World

    Line Width: 40

    Output  :               Hello World

    (14 spaces added to the left to center an 11-character string in 40 characters)

    Centering multiple lines

    Input   : Welcome
    to the Show
    Enjoy

    Line Width: 40

    Output  :                  Welcome
                  to the Show
                      Enjoy

    (Each line is padded individually based on its own character count)

    Centering text for a terminal banner

    Input   : SYSTEM READY

    Line Width: 80

    Output  :                                   SYSTEM READY

    (34 spaces added to center a 12-character string across 80 columns)

    Short line width example

    Input   : Hi

    Line Width: 20

    Output  :                   Hi

    (9 spaces added to center a 2-character string in 20 characters)

    Frequently Asked Questions

    How do you center text in a plain text file?

    Plain text files do not support visual alignment the way HTML or Word documents do. To center text in a plain text file, you add a calculated number of spaces to the left of each line so it appears centered within a fixed column width. This tool does that calculation automatically for every line in your input.

    How do I center text in a terminal or command line?

    Terminal output is monospace and fixed-width, so centering is done by padding lines with spaces. Paste your text into this tool, set the line width to match your terminal column count (often 80), and copy the padded output. It will display centered when printed to the terminal.

    What does line width mean in this tool?

    Line width is the total number of characters across the full line. If you set it to 60, each line of your output will be padded so the text sits in the middle of a 60-character-wide column. Lines that are longer than the width you set may not center correctly.

    How do I center text in a README file?

    Most README files render as Markdown, which supports HTML. You can use a div with text-align:center for rendered output. But for plain-text READMEs or for centering text in the raw file itself, this tool gives you the space-padded version.

    Can I center multiple lines at once?

    Yes. Paste as many lines as you need and all of them are centered in one click. Each line is padded individually based on its own length relative to the line width you set.

    How do I center text in Python?

    Python strings have a built-in center() method. "hello".center(60) returns the string padded to sit centered in a 60-character-wide field. For quick formatting outside of code, this tool does the same thing without writing any script.

    How does centering with spaces work?

    The tool counts the characters in each line, subtracts from the total line width, divides the remainder by two, and adds that many spaces to the left side of the line. So a 10-character line centered in a 60-character width gets 25 spaces added before it.

    What is the default line width?

    The default is set to 60 characters, which works for a lot of plain-text use cases. You can change it to any number that matches your target display width.

    Does this work with monospace fonts only?

    Yes, effectively. Centering by character count only looks correct in monospace fonts where every character is the same width. In proportional fonts, the spacing will look off because different characters take up different amounts of horizontal space.