﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head># 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), [`unde