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

# Common conversion helpers

> Every registered general-purpose helper, with signatures and examples for emptiness checks, conversions, and shared value handling.

## When to use these helpers

Use a conversion only after you understand the source value. A conversion can make an expression readable, but it cannot repair missing or incorrectly structured source data.

## Calling style

Call a helper as `isEmpty($.optional_note)`. Not every helper is available everywhere: validation, form, and document-template helpers have distinct context contracts. Editor suggestions are not proof that a helper is supported at runtime.

## Complete function reference

### `contains`

Checks if a string or array contains a specified substring

**Signature:** `contains(strOrArr, substring)`

**Example:**

```txt theme={null}
contains(["hello", "world"], "lo") // true
```

**Note:** It can also be written as a transform when the first value is the input: `value | contains(...)`.

### `indexOf`

Finds the index of the first occurrence of a substring in a string

**Signature:** `indexOf(str, substring)`

**Example:**

```txt theme={null}
indexOf("hello", "lo") // 3
```

**Note:** It can also be written as a transform when the first value is the input: `value | indexOf(...)`.

### `isEmpty`

Checks a falsy value, an empty array, or a trimmed empty text value. Do not pass a non-text object; use an explicit null/property check instead.

**Signature:** `isEmpty(value)`

**Example:**

```txt theme={null}
isEmpty($.supporting_documents)
```

**Availability:** General helper in shared builder and document-template runtimes; function and transform forms are available.

**Note:** It can also be written as a transform when the first value is the input: `value | isEmpty(...)`.

### `isNotEmpty`

Negates the active common isEmpty behavior. Use explicit null/array/text tests for a non-text object.

**Signature:** `isNotEmpty(value)`

**Example:**

```txt theme={null}
isNotEmpty($.service_category)
```

**Availability:** General helper in shared builder and document-template runtimes; function and transform forms are available.

**Note:** It can also be written as a transform when the first value is the input: `value | isNotEmpty(...)`.

### `lastIndexOf`

Finds the index of the last occurrence of a substring in a string

**Signature:** `lastIndexOf(str, substring)`

**Example:**

```txt theme={null}
lastIndexOf("hello", "lo") // 3
```

**Note:** It can also be written as a transform when the first value is the input: `value | lastIndexOf(...)`.

### `length`

Returns the length of a string or array

**Signature:** `length(strOrArr)`

**Example:**

```txt theme={null}
length("hello") // 5
```

**Note:** It can also be written as a transform when the first value is the input: `value | length(...)`.

### `reverse`

Reverses a string or array

**Signature:** `reverse(val)`

**Example:**

```txt theme={null}
reverse("hello") // "olleh"
```

**Note:** It can also be written as a transform when the first value is the input: `value | reverse(...)`.

### `toBoolean`

Converts a string to a boolean. Accepts 'true' (case-insensitive) as true.

**Signature:** `toBoolean(val)`

**Example:**

```txt theme={null}
toBoolean("true") // true
```

**Note:** It can also be written as a transform when the first value is the input: `value | toBoolean(...)`.

### `toInt`

Parses a value to an integer using optional radix

**Signature:** `toInt(value, radix?)`

**Example:**

```txt theme={null}
toInt("10") // 10
```

**Note:** It can also be written as a transform when the first value is the input: `value | toInt(...)`.

### `toNumber`

Converts a string to a number (or returns NaN if not possible)

**Signature:** `toNumber(val)`

**Example:**

```txt theme={null}
toNumber("12.5") // 12.5
```

**Note:** It can also be written as a transform when the first value is the input: `value | toNumber(...)`.

### `toStr`

Converts any value to its string representation

**Signature:** `toStr(value)`

**Example:**

```txt theme={null}
toStr(123) // "123"
```

**Note:** It can also be written as a transform when the first value is the input: `value | toStr(...)`.

## Before you publish

* Start with a known value and confirm the expected result.
* Handle null, empty text, and empty lists deliberately.
* Do not place secrets, access tokens, or sensitive personal data in an expression.
* Read [expression contexts and availability](/reference/expressions/contexts) before copying an expression between features.

![Common conversion helpers in KayanOS](https://kayanos.app/docs-images/en/reference/expressions-helpers-common.png)
