﻿---
title: ES|QL URL_ENCODE_COMPONENT function
description: 
url: https://www.elastic.co/elastic/docs-builder/docs/2844/reference/query-languages/esql/functions-operators/string-functions/url_encode_component
products:
  - Elasticsearch
---

# ES|QL URL_ENCODE_COMPONENT function
<applies-to>
  - Elastic Stack: Generally available since 9.2
</applies-to>


## Syntax

![Embedded](https://www.elastic.co/elastic/docs-builder/docs/2844/reference/query-languages/esql/images/functions/url_encode_component.svg)


## Parameters

<definitions>
  <definition term="string">
    The URL to encode.
  </definition>
</definitions>


## Description

URL-encodes the input. All characters are [percent-encoded](https://en.wikipedia.org/wiki/Percent-encoding) except for alphanumerics, `.`, `-`, `_`, and `~`. Spaces are encoded as `%20`.

## Supported types


| string  | result  |
|---------|---------|
| keyword | keyword |
| text    | keyword |


## Example

```esql
ROW u = "https://example.com/?x=foo bar&y=baz"
| EVAL u = URL_ENCODE_COMPONENT(u)
```


| u:keyword                                              |
|--------------------------------------------------------|
| https%3A%2F%2Fexample.com%2F%3Fx%3Dfoo%20bar%26y%3Dbaz |