# Padding Parser (/placeholders/parsers/padding)



## Usage [#usage]

To use the parser, insert the following syntax in your text:

`{padding(length:padChar:direction):text}`

* You can also reference this parser using the alias: pad

## Examples [#examples]

1. Left padding (default):

* Input: `{pad(4):42}`
* Output: `0042`

2. Custom padding character:

* Input: `{pad(4:*):42}`
* Output: `**42`

3. Right padding:

* Input: `{pad(4:0:right):42}`
* Output: `4200`

4. Center padding:

* Input: `{pad(4:-:both):42}`
* Output: `-42-`

## Available Parameters [#available-parameters]

| Parameter | Description                                   | Default | Example |
| --------- | --------------------------------------------- | ------- | ------- |
| length    | Target length for the string (required)       | -       | 4       |
| padChar   | Character used for padding                    | "0"     | \*      |
| direction | Padding direction: "left", "right", or "both" | "left"  | right   |

**Notes:**

* If the text is already equal to or longer than the specified length, it will be returned unchanged
* For "both" (center) padding, if the padding cannot be distributed evenly, the extra padding character will be added to the right side
