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

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