---
title: toBool() function
description: toBool() converts all values in the _value column to boolean types.
url: https://docs.influxdata.com/flux/v0/stdlib/universe/tobool/
estimated_tokens: 833
product: Flux
version: v0
publisher: InfluxData
canonical: https://docs.influxdata.com/flux/v0/stdlib/universe/tobool/
date: '2024-04-08T16:01:02-06:00'
lastmod: '2024-04-08T16:01:02-06:00'
---

* Flux 0.7.0+

InfluxDB support

`toBool()` converts all values in the `_value` column to boolean types.

#### Supported data types

* **string**: `true` or `false`
* **int**: `1` or `0`
* **uint**: `1` or `0`
* **float**: `1.0` or `0.0`

##### Function type signature

```js
(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B, _value: bool}]
```

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

## Parameters

### tables

Input data. Default is piped-forward data (`<-`).

## Examples

### Convert an integer \_value column to booleans

```js
import "sampledata"

sampledata.numericBool()
    |> toBool()
```

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

View example input and output

#### Input data

|       \_time       |\_value|\*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       |\_value|\*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       |\_value|\*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       |\_value|\*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/)
* [bool() function](/flux/v0/stdlib/universe/bool/)

[transformations](/flux/v0/tags/transformations/)[type-conversions](/flux/v0/tags/type-conversions/)
| _time | _value | *tag |
| --- | --- | --- |
| _time | _value | *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 | _value | *tag |
| --- | --- | --- |
| _time | _value | *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 | _value | *tag |
| --- | --- | --- |
| _time | _value | *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 | _value | *tag |
| --- | --- | --- |
| _time | _value | *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 |
