---
schema_version: "1"
id: 2abe8633e3ea41ae4566147bab3254319feb3074ff795a514d6f11201d54a3c8
title: to
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.4/dw-core-functions-to.md
canonical_url: https://docs.mulesoft.com/dataweave/2.4/dw-core-functions-to
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 744c5214cff0e37e6fd94b4848a1fcfc443aa8b4dcd7de9c9aa45e5a24253625
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
---
product: DataWeave
version: 2.4
---

# to

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

## to(from: Number, to: Number): Range

Returns a range with the specified boundaries.

The upper boundary is inclusive.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>from</code></p></td><td><p><code>Number</code> value that starts the range. The output includes the <code>from</code> value.</p></td></tr><tr><td><p><code>to</code></p></td><td><p><code>Number</code> value that ends the range. The output includes the <code>from</code> value.</p></td></tr></tbody></table>

### Example

This example lists a range of numbers from 1 to 10.

#### Source

```DataWeave
%dw 2.0
output application/json
---
{ "myRange": 1 to 10 }
```

#### Output

```JSON
{ "myRange": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] }
```

### Example

DataWeave treats a string as an array of characters. This example applies `to` to a string.

#### Source

```DataWeave
%dw 2.0
var myVar = "Hello World!"
output application/json
---
{
  indices2to6 : myVar[2 to 6],
  indicesFromEnd : myVar[6 to -1],
  reversal : myVar[11 to -0]
}
```

#### Output

```JSON
{
  "indices2to6": "llo W",
  "indicesFromEnd": "World!",
  "reversal": "!dlroW olleH"
}
```
