---
title: "levenshtein function in Strata | Oplema"
description: "Count the single-character inserts, deletes or substitutions needed to turn one string into another. For example, levenshtein('duck', 'db') returns 3."
url: "https://oplema.com/docs/strata/functions/levenshtein"
updated: "2026-11-04"
---

# levenshtein

Count the fewest character insertions, deletions and substitutions needed to turn one string into another. Uppercase and lowercase letters count as different.

Also available as editdist3.

## Try an expression

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

### Expression

```
levenshtein('duck', 'db')
```

### Result

```
3
```

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 | 3 |

## Arguments and types

```
levenshtein(s1, s2)
```

**s1**

Text

**s2**

Text

Supported signatures (1)

```
levenshtein(s1: VARCHAR, s2: VARCHAR) → BIGINT
```

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

[damerau\_levenshtein

Count the edits needed to turn one string into another, like levenshtein, but swapping two neighboring characters counts as one edit. Uppercase and lowercase letters count as different.

](https://oplema.com/docs/strata/functions/damerau-levenshtein)[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)[jaccard

Score how similar two strings are by the characters they share, from 0 to 1. Uppercase and lowercase letters count as different.

](https://oplema.com/docs/strata/functions/jaccard)[jaro\_similarity

The Jaro similarity between two strings. Characters of different cases (e.g., a and A) are considered different. Returns a number between 0 and 1. For similarity < score\_cutoff, 0 is returned instead. score\_cutoff defaults to 0.

](https://oplema.com/docs/strata/functions/jaro-similarity)

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

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