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

# wrapWith

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

## wrapWith(String, String): String

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

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

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