---
schema_version: "1"
id: aa51eb255b68b2f8ed6eb10a30157866889dcade7d4d15ae64bf5028c711f16d
title: ENCODE
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-sql-reference/scalar-func/string-func/encode.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/encode.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 24434b04f8f88aed7d5c4c18bfe19d281086af4e5265547dd85d191fbbe1f1e5
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# `ENCODE`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Encodes binary data into a textual representation.

## Syntax

```sql
encode(<data>, <format>)
```

## Arguments

### Required

- `<data>`: The binary data to encode.
- `<format>`: The format to use when encoding the string (`base64`, `hex`, or `escape`).

## Returns

Returns a text value that contains the encoded representation.

## Considerations

- The `escape` format converts zero bytes and high-bit-set bytes to octal sequences.

## Examples

### Encode to Base64

Encode binary data to base64.

```sql
SELECT encode('123\000\001', 'base64') AS result;
```

Returns `'MTIzXDAwMFwwMDE='`.

## Related Documentation

- [String Types](https://developer.salesforce.com/docs/data/data-cloud-query-guide/datatype/string.md)
