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

# 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._
