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

# rightPad

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

## rightPad(String, Number, 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 2.2.0. Supported by Mule 4.2 and later._

### 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(Null, Number, String): Null

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