---
schema_version: "1"
id: 7a54fc0b8b7cfc53dfb09412f83a6ca4329a74b0170158717bd8caa81411787f
title: levenshteinDistance
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dw-strings-functions-levenshteindistance.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dw-strings-functions-levenshteindistance
source_site: docs.mulesoft.com
content_type: documentation
content_hash: e3a874fd802a888f4ae3b47fbf6780faa45451a8278b58bb744bac13954e15aa
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
---

# levenshteinDistance

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## levenshteinDistance(a: String, b: String): Number

Returns the Levenshtein distance (or edit distance) between two strings.

_Introduced in DataWeave version 2.4.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>a</code></p></td><td><p>The first string.</p></td></tr><tr><td><p><code>b</code></p></td><td><p>The second string.</p></td></tr></tbody></table>

### Example

This example shows how `levenshteinDistance` behaves with different strings.

#### Source

```DataWeave
%dw 2.0
import levenshteinDistance from dw::core::Strings
output application/json
---
"kitten" levenshteinDistance "sitting"
```

#### Output

```Json
3
```
