---
title: base64 function
description: Learn the syntax of the base64 function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/base64
---

# `base64` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Converts `expr` to a base 64 string using [RFC2045 Base64 transfer encoding for MIME](https://datatracker.ietf.org/doc/html/rfc2045).

## Syntax

```
base64(expr)
```

## Arguments

* `expr`: A BINARY expression or a STRING which the function will interpret as BINARY.

## Returns

A STRING.

## Examples

```sql
> SELECT base64('Spark SQL');
 U3BhcmsgU1FM
```

## Related functions

* [`unbase64` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/unbase64.md)
