---
schema_version: "1"
id: deed9d5a3a5319d6df0a99224131a3758196a16ebd616660c11b1a2af3b425fd
title: "Handlebars Helper Function: encodeURI"
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/handlebars/reference/hb_http_helpers/mcn-handlebars-reference-http-encodeuri.md
canonical_url: https://developer.salesforce.com/docs/marketing/handlebars-for-marketing-cloud-next/references/mcn-handlebars-http-references/mcn-handlebars-reference-http-encodeuri.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 7abec80d4057262207f132ea8eeb9b1551c5773ac5d2c4f7c75c5d3743a54802
products:
  - Handlebars for Marketing Cloud Next
  - Marketing Cloud
---
# Handlebars Helper Function: encodeURI

Converts a string to a format that is safe to use in a URL.

This function encodes an entire string. To encode only a query string that follows a URL, use [encodeURIComponent](https://developer.salesforce.com/docs/marketing/handlebars-for-marketing-cloud-next/references/mcn-handlebars-http-references/mcn-handlebars-reference-http-encodeuricomponent.md).

## Availability

This helper is available in the Winter ’27 release of Marketing Cloud Next.

## Syntax

```handlebars
{{encodeURI stringToEncode onlySpaces=true|false}}
```

## Parameters

| Parameter        | Type    | Description                                                                                                                                                        |
| ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `stringToEncode` | String  | Required. The string to encode.                                                                                                                                    |
| `onlySpaces`     | Boolean | If `true`, encodes spaces as `%20` and ignores other characters. If `false`, encodes all characters that aren't safe to use in URLs. The default value is `false`. |

## Return Value

The function returns the URL-encoded string.

## Usage Example

This example encodes a string of text so that it's safe to include in a URL, converting all spaces and special characters.

```handlebars
{{encodeURI "Sample Text: example" onlySpaces=false}}
```

The function returns this URL-encoded string:

```text
Sample+Text%3a+example
```

## See Also

- [encodeURIcomponent](https://developer.salesforce.com/docs/marketing/handlebars-for-marketing-cloud-next/references/mcn-handlebars-http-references/mcn-handlebars-reference-http-encodeuricomponent.md)
