Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fstring%2Fpad.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fstring%2Fpad.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `pad`

## Description

**Alias for \[\`padLeft\`]\(./padleft.md).**

Adds characters to the beginning of a string until it reaches the desired length. If the string is longer than the target length, it is truncated from the end.

Note

The `fillWith` argument must be a single-character string.

## Syntax

Like many functions in DataPrime, `pad` supports<!-- --> [two notations](https://coralogix.com/docs/docs/dataprime/language-reference/functions-reference/.md),<!-- --> **function** and **method**. These interchangeable forms allow flexibility in how you structure expressions.

* Function notation
* Method notation

```
pad(value: string, charCount: number, fillWith: string): string
```

```
(value: string).pad(charCount: number, fillWith: string): string
```

## Arguments

| Name        | Type     | Required | Description                                                                                 |
| ----------- | -------- | -------- | ------------------------------------------------------------------------------------------- |
| `value`     | `string` | **true** | The string to pad                                                                           |
| `charCount` | `number` | **true** | Desired total length of the string; if smaller than current length, the string is truncated |
| `fillWith`  | `string` | **true** | The single character used for padding                                                       |

## Example

**Ensure all strings are the same length**

Consider the following documents:

```
{ "name": "Chris" }

{ "name": "David" }

{ "name": "John" }
```

Use `pad` to make all names 10 characters long:

### Example query

* Function notation
* Method notation

```
create name_padded from pad(name, 10, 'X')
```

```
create name_padded from name.pad(10, 'X')
```

### Example output

```
{

    "name": "Chris",

    "name_padded": "XXXXXChris"

}

{

    "name": "David",

    "name_padded": "XXXXXDavid"

}

{

    "name": "John",

    "name_padded": "XXXXXXJohn"

}
```
