Use Text Alignment Tool

Enter your data below to use the Text Alignment Tool

📌 Try these examples:
RESULT

Last updated

Text Alignment Tool Examples

The Text Alignment Tool adjusts text to left, right, center, or justified alignment within a specified column width. Below are practical examples for formatting terminal output, code comments, tables, and documents.

Left Alignment (Normalize Mixed Indentation)

// Input (mixed leading spaces)
    Hello World
  This is a paragraph.
      Some indented text.

// Output (left-aligned, leading whitespace stripped)
Hello World
This is a paragraph.
Some indented text.

Left alignment is the default for most text and is easiest to read for long passages. Use it to normalize text copied from sources with inconsistent indentation.

Right Alignment (Column Width: 40)

// Input
Hello
World
This is a longer line

// Output (right-aligned, width=40)
                                   Hello
                                   World
                   This is a longer line

Right alignment is standard for numbers in tables, where digit positions must align vertically.

Center Alignment (Column Width: 40)

// Input
Welcome
to
My Application

// Output (centered, width=40)
                Welcome
                  to
             My Application

Center alignment works well for titles, headings, and decorative text in terminal output or README files.

Justified Alignment (Column Width: 40)

// Input
The quick brown fox jumps over the lazy dog near the river bank.

// Output (justified, width=40)
The  quick  brown  fox  jumps  over the
lazy  dog  near  the  river  bank.

Justified text distributes extra spaces between words so both left and right edges align. The last line of each paragraph is left-aligned by convention.

Right-Aligned Number Table

// Input (numbers need right-alignment for readability)
Item         Qty   Price
Widget A     12    9.99
Widget B     3     149.00
Widget C     100   0.50
Total              1,659.88

// Output (right-aligned numbers, width=30)
Item         Qty        Price
Widget A      12         9.99
Widget B       3       149.00
Widget C     100         0.50
Total                1,659.88

Centered ASCII Art Banner

// Input (width=60)
*****
*   *
*****
*
*

// Output (centered, width=60)
                        *****
                        *   *
                        *****
                        *
                        *

Code Comment Block (Centered, Width=60)

// Input
==============================================
  DATABASE CONFIGURATION
  Author: Dev Team
  Last Updated: 2024-01-15
==============================================

// Output (centered in 60-char block)
//         ==============================================
//           DATABASE CONFIGURATION
//           Author: Dev Team
//           Last Updated: 2024-01-15
//         ==============================================

Terminal Menu (Centered, Width=50)

// Input
Main Menu
1. New Game
2. Load Game
3. Settings
4. Quit

// Output (centered, width=50)
                 Main Menu
               1. New Game
              2. Load Game
               3. Settings
                  4. Quit

Multi-Column Table with Mixed Alignment

// Left-align text columns, right-align number columns
// Column widths: Name=20, Status=10, Count=8, Total=10

Name                 Status      Count     Total
----                 ------      -----     -----
Alpha Service        Active          5    $12.50
Beta Service         Inactive        0     $0.00
Gamma Service        Active         42   $105.00
Delta Service        Pending         1     $2.50

Justified Paragraph for Documentation

// Input paragraph (width=60)
This tool converts temperature values between Celsius, Fahrenheit, Kelvin, and Rankine scales instantly and accurately.

// Output (justified, width=60)
This  tool  converts  temperature  values  between
Celsius,  Fahrenheit,  Kelvin,  and  Rankine scales
instantly and accurately.

Python Implementation of Text Alignment

def align_text(text, width, mode='left'):
    lines = text.splitlines()
    result = []
    for line in lines:
        stripped = line.strip()
        if mode == 'left':
            result.append(stripped.ljust(width))
        elif mode == 'right':
            result.append(stripped.rjust(width))
        elif mode == 'center':
            result.append(stripped.center(width))
        elif mode == 'justify':
            words = stripped.split()
            if len(words) <= 1:
                result.append(stripped.ljust(width))
                continue
            spaces = width - sum(len(w) for w in words)
            gaps = len(words) - 1
            base, extra = divmod(spaces, gaps)
            line_out = ''
            for i, word in enumerate(words[:-1]):
                line_out += word + ' ' * (base + (1 if i < extra else 0))
            line_out += words[-1]
            result.append(line_out)
    return '\n'.join(result)

# Examples
print(align_text("Hello\nWorld", 20, 'right'))
print(align_text("Hello\nWorld", 20, 'center'))

Common Alignment Use Cases

Paste your text into the Text Alignment Tool, choose your alignment mode and column width, and get perfectly formatted output ready to use.

Frequently Asked Questions

Simply enter your data, click the process button, and get instant results. All processing happens in your browser for maximum privacy and security.

Yes! Text Alignment Tool is completely free to use with no registration required. All processing is done client-side in your browser.

Absolutely! All processing happens locally in your browser. Your data never leaves your device, ensuring complete privacy and security.