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

# 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
```
