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

# underscore

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

## underscore(text: String): String

Replaces hyphens, spaces, and camel-casing in a string with underscores.

If no hyphens, spaces, and camel-casing are present, the output will match the input.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>text</code></p></td><td><p>The input string.</p></td></tr></tbody></table>

### Example

This example replaces the hyphens and spaces in the input. Notice that the input "customer" is not
modified in the output.

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Strings
output application/json
---
{
   "a" : underscore("customer"),
   "b" : underscore("customer-first-name"),
   "c" : underscore("customer NAME"),
   "d" : underscore("customerName")
}
```

#### Output

```JSON
{
   "a": "customer",
   "b": "customer_first_name",
   "c": "customer_name",
   "d": "customer_name"
}
```

## underscore(text: Null): Null

Helper function that enables `underscore` to work with a `null` value.
