String Left Aligner

Pads the end of every line with a fill character until it reaches a target width, left-aligning a block of text so its visible content lines up on the left while every line ends at the same column. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-23

Overview

Introduction

When lining up a list of labels, table-like plain text, or ASCII output, every line needs to end at the same column so the block reads as a clean rectangle.

Manually counting characters and adding trailing spaces to dozens of lines by hand is slow and error-prone.

What Is String Left Aligner?

A line padder that appends a fill character to the end of every line in a block of text until each line reaches a common target width.

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 Left Aligner Works

The tool splits the input on newlines and calls padEnd() on each line with the chosen width and fill character, then rejoins the lines with newlines.

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

When To Use String Left Aligner

Use it to line up a list of short labels, pad plain-text table columns, or prepare monospace output where every row needs a consistent width.

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.

Features

Advantages

  • Preserves the original left edge of every line exactly.
  • Supports any single fill character, not just spaces.
  • Pads each line independently, so lines already at or beyond the target width pass through untouched rather than being truncated to fit.

Limitations

  • Lines longer than the target width are left as-is rather than truncated.
  • Only pads to a fixed character width; it doesn't account for variable-width font rendering.

Examples

Padding short labels

Input

cat
elephant
fox

Output

cat.....
elephant
fox.....

With width=8 and fill character '.', each line is padded on the right to reach 8 characters.

Best Practices & Notes

Best Practices

  • Use a visible fill character like '.' or '-' while testing alignment, then switch to a space for the final output.
  • Measure your longest line before settling on a width, since anything longer is left unpadded and visibly breaks the right edge of the block.
  • Strip trailing whitespace afterwards if the padded text is going into a source file, where spaces at line ends are usually unwanted.

Developer Notes

Each line is padded independently with `String.prototype.padEnd(width, fillChar)`; lines already at or beyond `width` are returned unchanged since `padEnd()` is a no-op in that case.

String Left Aligner Use Cases

  • Lining up a list of short labels for a plain-text report
  • Preparing fixed-width columns for a monospace display
  • Padding filenames or codes to a uniform length before further processing

Common Mistakes

  • Forgetting that lines longer than the target width won't be shortened, so the block may still look uneven if inputs vary widely in length.
  • Assuming the fill can be several characters wide; the underlying padEnd repeats the pad string and cuts it off mid-way to hit the exact width.

Tips

  • Pick a width slightly larger than your longest expected line so future edits don't immediately exceed it.
  • Padding with a space gives invisible alignment that survives copy-paste, while a visible fill character makes the column boundary obvious while you are still adjusting the width.

References

Frequently Asked Questions