---
schema_version: "1"
id: 18e0694215d298f56a2803a815d681004dd53e96124b47b93bef8d81d402c672
title: hammingDistance
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.11/dw-strings-functions-hammingdistance.md
canonical_url: https://docs.mulesoft.com/dataweave/2.11/dw-strings-functions-hammingdistance
source_site: docs.mulesoft.com
content_type: documentation
content_hash: e02570e31008182b769119154357716a7e7fe357b61f7fabd8e6fe125eb20622
description: MuleSoft Documentation Site
release: "2.11"
latest: false
---
---
product: DataWeave
version: 2.11
---

# hammingDistance

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

## hammingDistance(a: String, b: String): Number | Null

Returns the Hamming 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 `hammingDistance` behaves with different strings.

#### Source

```DataWeave
%dw 2.0
import hammingDistance from dw::core::Strings
output application/json
---
"holu" hammingDistance "chau"
```

#### Output

```Json
3
```
