# TO_BASE64()

## Function description

The `TO_BASE64()` function is used to convert a string to a Base64-encoded string. If the argument is not a string, it is converted to a string before conversion. If the parameter is NULL, the result is NULL.

The Base64 encoded string can be decoded using the [`FROM_BASE64()`](https://omnifabric.cloudsigma.com/docs/reference/sql/Functions-and-Operators/String/from_base64.html.md) function.

## Function Syntax

```text
> TO_BASE64(str)
```

## Parameter definition

| Parameters | Description |
| ---- | ---- |
| str | Required parameters. To convert to Base64 encoded string |

## Example

```text
mysql> SELECT TO_BASE64('abc');
+----------------+
| to_base64(abc) |
+----------------+
| YWJj           |
+----------------+
1 row in set (0.00 sec)

mysql> SELECT TO_BASE64(255);
+----------------+
| to_base64(255) |
+----------------+
| MjU1           |
+----------------+
1 row in set (0.00 sec)

mysql> SELECT TO_BASE64(null);
+-----------------+
| to_base64(null) |
+-----------------+
| NULL            |
+-----------------+
1 row in set (0.01 sec)
```
