# parseBoolean

> This document is the Markdown version of [valibot.dev/api/parseBoolean/](https://valibot.dev/api/parseBoolean/). For the complete documentation index, see [llms.txt](https://valibot.dev/llms.txt).

Creates a parse boolean transformation action.

```ts
const Action = v.parseBoolean<TInput, TConfig, TMessage>(config, message);
```

## Generics

- `TInput` `extends any`
- `TConfig` `extends ParseBooleanConfig | undefined`
- `TMessage` `extends ErrorMessage<ParseBooleanIssue<TInput>> | undefined`

## Parameters

- `config` `TConfig`
- `message` `TMessage`

### Explanation

With `parseBoolean` you can parse certain "boolish" values into a plain boolean value (e.g. parsing environment variables). It supports both string and non-string values and the comparison is case-insensitive for strings.

By default, the truthy values are `true`, `1`, `"true"`, `"1"`, `"yes"`, `"y"`, `"on"`, and `"enabled"`. The falsy values are `false`, `0`, `"false"`, `"0"`, `"no"`, `"n"`, `"off"`, and `"disabled"`. You can override these defaults via the `config` argument.

## Returns

- `Action` `ParseBooleanAction<TInput, TConfig, TMessage>`

## Examples

The following examples show how `parseBoolean` can be used.

```ts
const EnvSchema = v.object({
  // Default behavior
  PROD_MODE: v.pipe(v.string(), v.parseBoolean()),

  // With custom config
  LOG_MODE: v.pipe(
    v.string(),
    v.parseBoolean({
      truthy: ['verbose', 'chatty', 'record'],
      falsy: ['silent', 'quiet', 'mute'],
    })
  ),
});
```

## Related

The following APIs can be combined with `parseBoolean`.

### Schemas

[`any`](/api/any.md), [`custom`](/api/custom.md), [`string`](/api/string.md)

### Methods

[`pipe`](/api/pipe.md)

### Utils

[`isOfKind`](/api/isOfKind.md), [`isOfType`](/api/isOfType.md)
