---
title: "bin function in Strata | Oplema"
description: "Convert a value to its binary representation, written as a string of zeros and ones. Write it as bin(string) in a Strata Formula or Filter."
url: "https://oplema.com/docs/strata/functions/bin"
updated: "2026-11-04"
---

# bin

Converts the string to binary representation.

Also available as to\_binary.

## Try an expression

In [Formula](https://oplema.com/docs/strata/prep/formula), enter the expression and set Output type to **VARCHAR**.

### Expression

```
bin('Aa')
```

### Result

```
'0100000101100001'
```

To use your own data, replace the example values with column names. Keep format strings and other options as written.

Try it live in Formula

Result
| id | result |
| --- | --- |
| 1 | 0100000101100001 |

## Arguments and types

```
bin(string)
```

**string**

Text

**value**

Number

Supported signatures (6)

```
bin(string: VARCHAR) → VARCHAR
bin(value: BIGINT) → VARCHAR
bin(value: BIGNUM) → VARCHAR
bin(value: HUGEINT) → VARCHAR
bin(value: UBIGINT) → VARCHAR
bin(value: UHUGEINT) → VARCHAR
```

The result type can depend on the input types. See DuckDB for the full argument rules.

## Things to know

If the first argument is missing, the result is NULL.

## Related functions

[hex

Convert a value to hexadecimal text.

](https://oplema.com/docs/strata/functions/hex)[unbin

Converts a value from binary representation to a blob.

](https://oplema.com/docs/strata/functions/unbin)[format\_bytes

Convert a byte count to a readable size using units based on powers of 2, such as KiB, MiB and GiB. Also available as pg\_size\_pretty.

](https://oplema.com/docs/strata/functions/format-bytes)[from\_base64

Decode base64 text into binary data.

](https://oplema.com/docs/strata/functions/from-base64)

[Browse text](https://oplema.com/docs/strata/functions#text) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/text.html#binstring)

Function metadata from DuckDB, used under the [MIT license](https://github.com/duckdb/duckdb/blob/v1.5.4/LICENSE).
