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

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