---
schema_version: "1"
id: 634f28c690a8fffaaf114e086e77e6ad1ad91e282a9199c34f991d5111c247a8
title: toBinary
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.11/dw-numbers-functions-tobinary.md
canonical_url: https://docs.mulesoft.com/dataweave/2.11/dw-numbers-functions-tobinary
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 8f2090ed5ccf016dd1c70be29e531364bebb541825a18be6520cc60f795e931a
description: MuleSoft Documentation Site
release: "2.11"
latest: false
---
---
product: DataWeave
version: 2.11
---

# toBinary

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

## toBinary(number: Number): String

Transforms a decimal number into a binary number.

_Introduced in DataWeave version 2.2.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>number</code></p></td><td><p>The input number.</p></td></tr></tbody></table>

### Example

This example shows how the `toBinary` behaves with different inputs.

#### Source

```DataWeave
%dw 2.0
import toBinary from dw::core::Numbers
output application/json
---
{
    a: toBinary(-2),
    b: toBinary(100000000000000000000000000000000000000000000000000000000000000),
    c: toBinary(0),
    d: toBinary(null),
    e: toBinary(2),
}
```

#### Output

```JSON
{
  "a": "-10",
  "b": "11111000111010111010110100101011100001001110000011010101100010111101001011100000100010011000011101100101101001111101111010110010010100110010100100000000000000000000000000000000000000000000000000000000000000",
  "c": "0",
  "d": null,
  "e": "10"
}
```

## toBinary(number: Null): Null

Helper function that enables `toBinary` to work with null value.

_Introduced in DataWeave version 2.2.0._
