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

# encodeURI

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

## encodeURI(text: String): String

Encodes a URI with UTF-8 escape sequences.

Applies up to four escape sequences for characters composed of two "surrogate" characters. The
function assumes that the URI is a complete URI, so it does not encode reserved characters that have
special meaning.

The function _does not encode these characters_ with UTF-8 escape sequences:

<table><colgroup><col> <col></colgroup><thead><tr><th>Type (not escaped)</th><th>Examples</th></tr></thead><tbody><tr><td><p>Reserved characters</p></td><td><p>; , / ? : @ &amp; = $</p></td></tr><tr><td><p>Unescaped characters</p></td><td><p>alphabetic, decimal digits, - _ . ! ~ * ' ( )</p></td></tr><tr><td><p>Number sign</p></td><td><p>#</p></td></tr></tbody></table>

### 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 URI to encode.</p></td></tr></tbody></table>

### Example

This example shows encodes spaces in one URL and lists some characters that do not get encoded in
the `not_encoded` string.

#### Source

```DataWeave
%dw 2.0
import * from dw::core::URL
output application/json
---
{
    "encodeURI" : encodeURI("http://asd/ text to decode /%/\"\\/text"),
    "not_encoded": encodeURI("http://:;,/?:@&=\$_-_.!~*'()")
}
```

#### Output

```JSON
{
  "encodeURI": "http://asd/%20text%20to%20decode%20/%25/%22%5C/text",
  "not_encoded": "http://:;,/?:@&=$_-_.!~*'()"
}
```
