String Right Aligner

Pads every line on the left with spaces so it right-aligns within a fixed-width column, like the numeric column of a plain-text table or report. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-22

Overview

Introduction

Plain-text tables and reports often need a numeric or short-text column right-aligned for readability.

This tool applies that alignment to every line of your input at once.

What Is String Right Aligner?

A line-by-line right-aligner that space-pads each line on the left to a fixed column width, so shorter lines line up flush-right against longer ones.

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 String Right Aligner Works

Input is split into lines, and each line is individually padded on the left with spaces to the target width using padStart().

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

When To Use String Right Aligner

Use it when formatting a plain-text table's numeric column, or aligning a list of short codes for a monospace display.

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 String Left Padder and String Center Aligner.

Features

Advantages

  • Processes every line at once instead of padding each individually.
  • Uses spaces specifically, matching typical visual-alignment expectations.
  • Pads each line independently, so a column still aligns correctly even when the lines differ widely in length.

Limitations

  • Only pads with spaces; use Left-pad a String if you need a different pad character.
  • Assumes a monospace font for the alignment to actually look aligned.

Examples

Aligning a short numeric column

Input

1
22
333

Output

       1
      22
     333

Each line is right-aligned within an 8-character column.

Best Practices & Notes

Best Practices

  • View the result in a monospace font; proportional fonts won't show true visual alignment.
  • Trim leading whitespace before aligning, since existing indentation counts toward the width and pushes that line out of the column.
  • Choose a width at least as wide as your longest line, because anything longer is returned unpadded and breaks the alignment.

Developer Notes

Each line is padded independently via padStart(width, " "), rather than padding the whole multi-line string as one unit, which would incorrectly measure length across newlines.

String Right Aligner Use Cases

  • Right-aligning a numeric column in a plain-text report
  • Aligning short codes for a monospace terminal display
  • Formatting output for a fixed-width log format

Common Mistakes

  • Viewing the output in a proportional font, where alignment won't visually line up.
  • Aligning text containing multi-byte characters and expecting perfect columns, since padStart counts UTF-16 units rather than display width.

Tips

  • Use Left-pad a String instead if you need a non-space pad character.
  • Right alignment is the conventional choice for numeric columns, where lining up the place values makes the numbers easy to compare at a glance.

References

Frequently Asked Questions