> ## Documentation Index
> Fetch the complete documentation index at: https://errand.nuvrel.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# tonumber

> Convert a value to a number.

`tonumber(v)` converts `v` to a number. Numeric strings like `"42"` or `"3.14"` are parsed. Numbers pass through unchanged.

## Signature

```
tonumber(v any) number
```

## Example

Read a timeout value from an environment variable and use it as a number in a command:

```hcl theme={null}
computed "timeout" {
  description = "Connection timeout in seconds"
  expression  = tonumber(env("CONNECT_TIMEOUT", "30"))
}

task "health-check" {
  description = "Wait for the service to be ready"
  commands    = ["./bin/wait-for-ready --timeout ${computed.timeout}"]
}
```

## Notes

* The string must be a valid decimal number. Non-numeric strings produce an error.
* For integers in non-decimal bases (hex, binary), use [`parseint`](/functions/number/parseint) instead.
* `tonumber` is most useful when a numeric value comes from an environment variable or a string expression.
