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

# 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"]}
```
