---
schema_version: "1"
id: 32fdaa7c16dbe1e1e0681e8272297fa01a9641e7fe7673b67ed5b8d77a4208df
title: toArray
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dw-coercions-functions-toarray.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dw-coercions-functions-toarray
source_site: docs.mulesoft.com
content_type: documentation
content_hash: adaeef259165a2e14cdcc8b4245e554e70ddeebeb9697401e344e40317477ccf
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
---

# toArray

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

## toArray(@StreamCapable text: String): Array<String>

Splits a `String` value into an `Array` of characters.

_Introduced in DataWeave version 2.4.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 <code>String</code> value to transform into an <code>Array</code> of characters (a <code>Array&lt;String&gt;</code> type).</p></td></tr></tbody></table>

### Example

This example shows how `toArray` behaves with different inputs.

#### Source

```DataWeave
%dw 2.0
import * from dw::util::Coercions
output application/json indent=false
---
{
  a: toArray(""),
  b: toArray("hola")
}
```

#### Output

```Json
{"a": [],"b": ["h","o","l","a"]}
```
