---
schema_version: "1"
id: 5561583db6bedf193382885c34d45bbc937f4e4440334576c2e8e1c218e0c43f
title: capitalize
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.12/dw-strings-functions-capitalize.md
canonical_url: https://docs.mulesoft.com/dataweave/2.12/dw-strings-functions-capitalize
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 3b5a3689481086fea60f5e3b4bec9efab6fa8e6dfa88ab44f334df9ee7b130f7
description: MuleSoft Documentation Site
release: "2.12"
latest: false
---
---
product: DataWeave
version: 2.12
---

# capitalize

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

## capitalize(text: String): String

Capitalizes the first letter of each word in a string.

The function treats every non-alphabetic character as a separator and replaces underscores with
spaces. For example, `capitalize("a*s_b’s")` results in `"A*S B’S"`.

### 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 string to capitalize.</p></td></tr></tbody></table>

### Example

This example capitalizes a set of strings.

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Strings
output application/json
---
{
  "a" : capitalize("customer"),
  "b" : capitalize("customer_first_name"),
  "c" : capitalize("customer NAME"),
  "d" : capitalize("customerName"),
  "e" : capitalize("a*s_b’s")
}
```

#### Output

```JSON
{
  "a": "Customer",
  "b": "Customer First Name",
  "c": "Customer Name",
  "d": "Customer Name",
  "e": "A*S B’S"
}
```

## capitalize(text: Null): Null

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