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

# underscore

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

## underscore(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(Null): Null

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