---
schema_version: "1"
id: 5277e02de3a50f119311fec76aad83a35b96fe000a1d2202a112ee54f546734b
title: rightPad
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.4/dw-strings-functions-rightpad.md
canonical_url: https://docs.mulesoft.com/dataweave/2.4/dw-strings-functions-rightpad
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 8df48fe84e79a28fb2640ab9ba648a0ccb0e5e094ed642eebc9a772187be41ad
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
---
product: DataWeave
version: 2.4
---

# rightPad

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## rightPad(text: String, size: Number, padChar: String = " "): String

The specified `text` is _right_\-padded to the `size` using the `padText`. By default `padText` is
`" "`.

Returns right padded `String` or original `String` if no padding is necessary.

_Introduced in DataWeave version 2.2.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>text</code></p></td><td><p>The input string.</p></td></tr><tr><td><p><code>size</code></p></td><td><p>The size to pad to.</p></td></tr><tr><td><p><code>padText</code></p></td><td><p>The text to pad with. It defaults to one space if not specified.</p></td></tr></tbody></table>

### Example

This example shows how `rightPad` behaves with different inputs and sizes.

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Strings
output application/json
---
{
  "a": rightPad(null, 3),
  "b": rightPad("", 3),
  "c": rightPad("bat", 5),
  "d": rightPad("bat", 3),
  "e": rightPad("bat", -1)
}
```

#### Output

```JSON
{
  "a": null,
  "b": "   ",
  "c": "bat  ",
  "d": "bat",
  "e": "bat"
}
```

## rightPad(text: Null, size: Any, padText: Any = " "): Null

Helper function that enables `rightPad` to work with a `null` value.

_Introduced in DataWeave version 2.2.0._
