# `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](/docs/data/data-cloud-query-guide/references/dc-sql-reference/string.md)
