---
schema_version: "1"
id: 84d03938d13e368db2377d57253576aa74fb82980a165568fc05d6ffe8d0e2ab
title: joinBy
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.6/dw-core-functions-joinby.md
canonical_url: https://docs.mulesoft.com/dataweave/2.6/dw-core-functions-joinby
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 9c83c4b5ce4bc2a3929991ed0082ac7b4784e7b85b9fe54ecbc98c218041070b
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
---
product: DataWeave
version: 2.6
---

# joinBy

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

## joinBy(elements: Array<StringCoerceable>, separator: String): String

Merges an array into a single string value and uses the provided string as a separator between each
item in the list.

Note that `joinBy` performs the opposite task of `splitBy`.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>elements</code></p></td><td><p>The input array.</p></td></tr><tr><td><p><code>separator</code></p></td><td><p>A <code>String</code> used to join elements in the list.</p></td></tr></tbody></table>

### Example

This example joins the elements with a hyphen (`-`).

#### Source

```DataWeave
%dw 2.0
output application/json
---
{ "hyphenate" : ["a","b","c"] joinBy "-" }
```

#### Output

```JSON
{ "hyphenate": "a-b-c" }
```

## joinBy(n: Null, separator: Any): Null

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

_Introduced in DataWeave version 2.4.0._
