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

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