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

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