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

# wrapWith

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

## wrapWith(text: String, wrapper: String): String

Wraps the specified `text` with the given `wrapper`.

_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>wrapper</code></p></td><td><p>The content used to wrap.</p></td></tr></tbody></table>

### Example

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

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Strings
output application/json
---
{
  "a": wrapWith(null, "'"),
  "b": wrapWith("", "'"),
  "c": wrapWith("ab", "x"),
  "d": wrapWith("'ab'", "'"),
  "e": wrapWith("ab", "'")
}
```

#### Output

```JSON
{
  "a": null,
  "b": "''",
  "c": "xabx",
  "d": "''ab''",
  "e": "'ab'"
}
```

## wrapWith(text: Null, wrapper: Any): Null

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

_Introduced in DataWeave version 2.2.0._
