Center Aligner

Pads every line evenly on both sides with a chosen character so it sits centered within a fixed-width column, useful for banner text or centered headings in plain-text output. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-22

Overview

Introduction

Centered headings and banner text in plain-text output need padding split evenly on both sides.

This tool does that for every line of your input.

What Is Center Aligner?

A centering tool that computes each line's total needed padding and splits it between the left and right sides, using your chosen pad character.

It runs entirely client-side as part of this site's String Tools collection, so nothing you paste is ever uploaded to a server.

How Center Aligner Works

For each line shorter than the target width, the tool computes the total padding needed, floors half of it for the left side, and puts the remainder on the right.

The transformation happens synchronously in JavaScript the moment you type, with no network round trip involved.

When To Use Center Aligner

Use it for centering a heading or banner in a plain-text file, README, or terminal output.

It's a fast way to get the answer without opening a code editor, a REPL, or writing a one-off script just to check.

Often used alongside Left Padder and Right Padder.

Features

Advantages

  • Handles multi-line input, centering every line independently.
  • Supports any single pad character, not just spaces.

Limitations

  • Assumes a monospace font for the centering to visually line up.
  • Doesn't account for full-width or multi-byte characters when measuring line length.

Examples

Centering a heading

Input

Hi

Output

    Hi    

With target width 10 and a space pad character, four spaces are added on each side.

Best Practices & Notes

Best Practices

  • View the result in a monospace font to confirm true visual centering.
  • Use a visible pad character like '*' or '-' for a banner effect.

Developer Notes

Padding is split with `Math.floor(totalPad / 2)` on the left and the remainder on the right, so an odd total always biases the extra character to the right side, a common convention for centered text.

Center Aligner Use Cases

  • Centering a heading in a plain-text README or changelog
  • Creating a banner effect around a short message
  • Formatting a centered title for terminal output

Common Mistakes

  • Expecting perfectly even padding when the total needed is an odd number.

Tips

  • Use a decorative pad character like '*' or '=' for banner-style centered text.

References

Frequently Asked Questions