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

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