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

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