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

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