---
schema_version: "1"
id: 21a5e04df1eb5fdb7c1f4c1067cd2a12044775ab78ac1387db832d30c6de8b72
title: toBoolean
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.4/dw-coercions-functions-toboolean.md
canonical_url: https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-toboolean
source_site: docs.mulesoft.com
content_type: documentation
content_hash: be608812fd7811ffd97297fffc297f6696af80bc49a712f0a7a89ced6f8a5228
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
---
product: DataWeave
version: 2.4
---

# toBoolean

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

## toBoolean(str: String): Boolean

Transform a `String` value into a `Boolean` value.

_Introduced in DataWeave version 2.4.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>str</code></p></td><td><p>The <code>String</code> value to transform into a <code>Boolean</code> value.</p></td></tr></tbody></table>

### Example

This example shows how `toBoolean` behaves with different inputs.

#### Source

```DataWeave
%dw 2.0
import * from dw::util::Coercions
output application/json
---
{
  a: toBoolean("true"),
  b: toBoolean("false"),
  c: toBoolean("FALSE"),
  d: toBoolean("TrUe")
}
```

#### Output

```Json
{
  "a": true,
  "b": false,
  "c": false,
  "d": true
}
```
