Skip to main content

Description

Pads the end (right side) of a string with a specified character until it reaches the desired length.

Syntax

Parameters

Returns

Type: string The padded string. If the original string is already longer than the target length, it is returned unchanged. Returns null if input is null.

Examples

Example 1: Basic Right Padding

Output:

Example 2: Creating Fixed-Width Fields

Output:

Example 3: Building Formatted Tables

Notes

  • Returns null if input is null
  • Converts numbers to strings automatically
  • Default padding character is a space
  • If string is already longer than target length, returns original string
  • Useful for creating aligned columns, fixed-width output, or formatted tables

See Also

Frequently Asked Questions

The original string is returned unchanged — no truncation occurs.
The default padding character is a space ' ' if no padChar argument is provided.