Use Text Padding Tool

Enter your data below to use the Text Padding Tool

📌 Try these examples:
RESULT

Last updated

Text Padding Tool Examples

The Text Padding Tool adds characters to text strings to reach a specified length, enabling fixed-width formatting for tables, terminal output, and data exchange formats. Below are practical examples for left, right, and center padding.

Left Padding (Right-Align)

// Pad numbers to width 8 with spaces (right-align)
Input:  "42"
Output: "      42"  (6 spaces + content)

Input:  "1234"
Output: "    1234"  (4 spaces + content)

Input:  "99999999"
Output: "99999999"  (already at target width)

Right Padding (Left-Align)

// Pad text to width 20 with spaces (left-align)
Input:  "Alice"
Output: "Alice               "  (content + 15 spaces)

Input:  "Bob"
Output: "Bob                 "  (content + 17 spaces)

Input:  "Christopher"
Output: "Christopher         "  (content + 9 spaces)

Center Padding

// Center text in width 20 with spaces
Input:  "Hello"
Output: "       Hello        "  (7 spaces + content + 8 spaces)

Input:  "Hi"
Output: "         Hi         "  (9 spaces + content + 9 spaces)

Zero Padding for Numbers

// Zero-pad integers to width 6
1       → 000001
42      → 000042
999     → 000999
12345   → 012345
999999  → 999999

// Use cases:
// Invoice numbers: INV-000042
// Order IDs:       ORD-001234
// File sequences:  frame_000001.png, frame_000002.png
// Zip codes:       00501 (leading zero preserved)

Fixed-Width Table Formatting

// Column widths: Name=20, Status=10, Count=6, Total=10
// Name: left-aligned (right-padded)
// Status: left-aligned (right-padded)
// Count: right-aligned (left-padded)
// Total: right-aligned (left-padded)

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

Custom Padding Character

// Pad with dashes (separator line)
Input:  "Section Title"
Width:  40
Char:   -
Mode:   center
Output: "------------- Section Title -----------"

// Pad with equals (header separator)
Input:  ""
Width:  60
Char:   =
Output: "============================================================"

// Pad with dots (table of contents)
Input:  "Introduction"
Width:  40
Char:   .
Mode:   right
Output: "Introduction........................"

Batch Padding (Multiple Strings)

// Input list (right-pad to width 15)
Alice
Bob
Christopher
Dave
Eve

// Output (all padded to width 15)
Alice          
Bob            
Christopher    
Dave           
Eve            

// Now columns align in a table:
Alice           | Engineer    | 5 years
Bob             | Designer    | 3 years
Christopher     | Manager     | 8 years
Dave            | Developer   | 2 years
Eve             | Analyst     | 6 years

Fixed-Width Data Format (Legacy Systems)

// EDI / mainframe fixed-width record format
// Field definitions:
// Positions 1-10:  Customer ID (right-padded with spaces)
// Positions 11-30: Customer Name (right-padded with spaces)
// Positions 31-40: Amount (left-padded with zeros)
// Positions 41-48: Date (YYYYMMDD)

// Example record:
CUST001   Alice Smith         0000150020240115

// Breakdown:
"CUST001   "  // Customer ID, width 10, right-padded
"Alice Smith         "  // Name, width 20, right-padded
"0000150.0"  // Amount, width 10, left-padded with zeros
"20240115"   // Date, width 8

Programming Language Equivalents

// JavaScript
"42".padStart(8)         // "      42"  (left pad with spaces)
"42".padStart(8, '0')    // "00000042"  (left pad with zeros)
"Hello".padEnd(10)       // "Hello     " (right pad with spaces)
"Hi".padEnd(10, '-')     // "Hi--------" (right pad with dashes)

// Python
"42".rjust(8)            # "      42"
"42".zfill(8)            # "00000042"
"Hello".ljust(10)        # "Hello     "
"Hi".center(10, '-')     # "----Hi----"

// Java
String.format("%8d", 42)         // "      42"
String.format("%-10s", "Hello")  // "Hello     "
String.format("%08d", 42)        // "00000042"

// Go
fmt.Sprintf("%8d", 42)           // "      42"
fmt.Sprintf("%-10s", "Hello")    // "Hello     "
fmt.Sprintf("%08d", 42)          // "00000042"

Padding for Terminal Progress Display

// Progress bar using padding
function progressBar(percent, width = 40) {
  const filled = Math.round(percent / 100 * width);
  const bar = '█'.repeat(filled).padEnd(width, '░');
  return `[${bar}] ${String(percent).padStart(3)}%`;
}

progressBar(0)   // [░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0%
progressBar(50)  // [████████████████████░░░░░░░░░░░░░░░░░░░░]  50%
progressBar(100) // [████████████████████████████████████████] 100%

Common Padding Use Cases

Enter your text, set the target width, choose padding character and alignment, and get perfectly padded 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 Padding 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.