---
title: bool() function
description: bool() converts a value to a boolean type.
url: https://docs.influxdata.com/flux/v0/stdlib/universe/bool/
estimated_tokens: 958
product: Flux
version: v0
publisher: InfluxData
canonical: https://docs.influxdata.com/flux/v0/stdlib/universe/bool/
date: '2024-04-08T16:01:02-06:00'
lastmod: '2024-04-08T16:01:02-06:00'
---

* Flux 0.7.0+

InfluxDB support

`bool()` converts a value to a boolean type.

##### Function type signature

```js
(v: A) => bool
```

For more information, see [Function type signatures](/flux/v0/function-type-signatures/).

## Parameters

### v

(Required)
Value to convert.

## Examples

* [Convert strings to booleans](#convert-strings-to-booleans)
* [Convert numeric values to booleans](#convert-numeric-values-to-booleans)
* [Convert all values in a column to booleans](#convert-all-values-in-a-column-to-booleans)

### Convert strings to booleans

```
bool(v: "true")

// Returns true
bool(v: "false")// Returns false

```

### Convert numeric values to booleans

```
bool(v: 1.0)

// Returns true
bool(v: 0.0)

// Returns false
bool(v: 1)

// Returns true
bool(v: 0)

// Returns false
bool(v: uint(v: 1))

// Returns true
bool(v: uint(v: 0))// Returns false

```

### Convert all values in a column to booleans

If converting the `_value` column to boolean types, use `toBool()`.
If converting columns other than `_value`, use `map()` to iterate over each
row and `bool()` to convert a column value to a boolean type.

```js
data
    |> map(fn: (r) => ({r with powerOn: bool(v: r.powerOn)}))
```

[](#view-example-input-and-output)

View example input and output

#### Input data

|       \_time       |powerOn|\*tag|
|--------------------|-------|-----|
|2021-01-01T00:00:00Z|   1   | t1  |
|2021-01-01T00:00:10Z|   1   | t1  |
|2021-01-01T00:00:20Z|   0   | t1  |
|2021-01-01T00:00:30Z|   1   | t1  |
|2021-01-01T00:00:40Z|   0   | t1  |
|2021-01-01T00:00:50Z|   0   | t1  |

|       \_time       |powerOn|\*tag|
|--------------------|-------|-----|
|2021-01-01T00:00:00Z|   0   | t2  |
|2021-01-01T00:00:10Z|   1   | t2  |
|2021-01-01T00:00:20Z|   0   | t2  |
|2021-01-01T00:00:30Z|   1   | t2  |
|2021-01-01T00:00:40Z|   1   | t2  |
|2021-01-01T00:00:50Z|   0   | t2  |

#### Output data

|       \_time       |powerOn|\*tag|
|--------------------|-------|-----|
|2021-01-01T00:00:00Z| true  | t1  |
|2021-01-01T00:00:10Z| true  | t1  |
|2021-01-01T00:00:20Z| false | t1  |
|2021-01-01T00:00:30Z| true  | t1  |
|2021-01-01T00:00:40Z| false | t1  |
|2021-01-01T00:00:50Z| false | t1  |

|       \_time       |powerOn|\*tag|
|--------------------|-------|-----|
|2021-01-01T00:00:00Z| false | t2  |
|2021-01-01T00:00:10Z| true  | t2  |
|2021-01-01T00:00:20Z| false | t2  |
|2021-01-01T00:00:30Z| true  | t2  |
|2021-01-01T00:00:40Z| true  | t2  |
|2021-01-01T00:00:50Z| false | t2  |

#### Related

* [Work with booleans](/flux/v0/data-types/basic/bool/)
* [toBool() function](/flux/v0/stdlib/universe/tobool/)

[type-conversions](/flux/v0/tags/type-conversions/)
| _time | powerOn | *tag |
| --- | --- | --- |
| _time | powerOn | *tag |
| 2021-01-01T00:00:00Z | 1 | t1 |
| 2021-01-01T00:00:10Z | 1 | t1 |
| 2021-01-01T00:00:20Z | 0 | t1 |
| 2021-01-01T00:00:30Z | 1 | t1 |
| 2021-01-01T00:00:40Z | 0 | t1 |
| 2021-01-01T00:00:50Z | 0 | t1 |

| _time | powerOn | *tag |
| --- | --- | --- |
| _time | powerOn | *tag |
| 2021-01-01T00:00:00Z | 0 | t2 |
| 2021-01-01T00:00:10Z | 1 | t2 |
| 2021-01-01T00:00:20Z | 0 | t2 |
| 2021-01-01T00:00:30Z | 1 | t2 |
| 2021-01-01T00:00:40Z | 1 | t2 |
| 2021-01-01T00:00:50Z | 0 | t2 |

| _time | powerOn | *tag |
| --- | --- | --- |
| _time | powerOn | *tag |
| 2021-01-01T00:00:00Z | true | t1 |
| 2021-01-01T00:00:10Z | true | t1 |
| 2021-01-01T00:00:20Z | false | t1 |
| 2021-01-01T00:00:30Z | true | t1 |
| 2021-01-01T00:00:40Z | false | t1 |
| 2021-01-01T00:00:50Z | false | t1 |

| _time | powerOn | *tag |
| --- | --- | --- |
| _time | powerOn | *tag |
| 2021-01-01T00:00:00Z | false | t2 |
| 2021-01-01T00:00:10Z | true | t2 |
| 2021-01-01T00:00:20Z | false | t2 |
| 2021-01-01T00:00:30Z | true | t2 |
| 2021-01-01T00:00:40Z | true | t2 |
| 2021-01-01T00:00:50Z | false | t2 |
