---
title: "to_base function in Strata | Oplema"
description: "Convert a number to text in a base you choose, with optional padding using leading zeros. For example, to_base(42, 16, 5) returns '0002A'."
url: "https://oplema.com/docs/strata/functions/to-base"
updated: "2026-11-04"
---

# to\_base

Converts number to a string in the given base radix, optionally padding with leading zeros to min\_length.

## Try an expression

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

### Expression

```
to_base(42, 16, 5)
```

### Result

```
'0002A'
```

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 | 0002A |

## Arguments and types

```
to_base(number, radix, min_length)
```

**number**

Number

**radix**

Number

**min\_length**

Number

Supported signatures (2)

```
to_base(number: BIGINT, radix: INTEGER) → VARCHAR
to_base(number: BIGINT, radix: INTEGER, min_length: INTEGER) → 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

[from\_base64

Decode base64 text into binary data.

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

Calculate the Hamming distance between two strings: the number of positions where their characters differ. Both strings must have the same length, and uppercase and lowercase letters count as different.

](https://oplema.com/docs/strata/functions/hamming)[to\_base64

Encode binary data as base64 text.

](https://oplema.com/docs/strata/functions/to-base64)[bin

Converts the string to binary representation.

](https://oplema.com/docs/strata/functions/bin)

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

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