> For the complete documentation index, see [llms.txt](https://docs.datajet-app.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datajet-app.com/liquid/filters/boolean.md).

# boolean

Casts a value to `true` or `false`, recognizing the textual booleans that CSV files, metafields and form fields carry.

```liquid
{% assign active = row.active | boolean %}
```

## Syntax

```liquid
{{ value | boolean }}
```

| Parameter | Description                       |
| --------- | --------------------------------- |
| `value`   | Any value to convert to a boolean |

## Return Value

Returns `true` or `false`.

## Examples

**Read a flag from a CSV column:**

```liquid
{% assign rows = file.content | parse_csv %}
{% for row in rows %}
  {% if row.discontinued | boolean %}
    {% assign to_archive = to_archive | push: row.sku %}
  {% endif %}
{% endfor %}
```

Without the cast, `{% if row.discontinued %}` is **true** for the string `"false"` — any non-empty string is truthy in Liquid.

**Normalize a metafield before writing it back:**

```liquid
{% assign subscribed = customer.metafield.value | boolean %}
{% json %}
{ "subscribed": {{ subscribed | json }} }
{% endjson %}
```

## Notes

* `false`, `f`, `no`, `n`, `off`, `0` and `""` become `false` (case-insensitive, surrounding whitespace ignored)
* `true`, `t`, `yes`, `y`, `on` and `1` become `true`
* Any other non-empty string is `true`, matching Liquid's own truthiness
* Numbers follow the usual rule: `0` is `false`, everything else is `true`
* `nil` and undefined are `false`; arrays and objects are `true`, including empty ones
* See also: `integer`, `is_number`, `type`
