# toString

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

Creates a to string transformation action.

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

## Generics

- `TInput` `extends any`
- `TMessage` `extends ErrorMessage<ToStringIssue<TInput>> | undefined`

## Parameters

- `message` `TMessage`

### Explanation

With `toString` you can transform the input to a string. If the input cannot be transformed, you can use `message` to customize the error message.

## Returns

- `Action` `ToStringAction<TInput, TMessage>`

## Examples

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

### String schema

Schema to validate a number and transform it to a string.

```ts
const StringSchema = v.pipe(v.number(), v.toString());
```

## Related

The following APIs can be combined with `toString`.

### Schemas

[`any`](/api/any.md), [`bigint`](/api/bigint.md), [`boolean`](/api/boolean.md), [`custom`](/api/custom.md), [`date`](/api/date.md), [`null`](/api/null.md), [`number`](/api/number.md), [`symbol`](/api/symbol.md), [`undefined`](/api/undefined.md), [`unknown`](/api/unknown.md)

### Methods

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

### Utils

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