---
title: fn::toString
url: /docs/esc/concepts/builtin-functions/fn-to-string/
---
The `fn::toString` built-in function encodes a value as its string representation. This can be used to encode values for use in positions that only accept strings. If any input to `fn::toString` is a secret, the encoded values is also a secret.

- Boolean values are encoded as `true` or `false`
- Number values are encoded as the decimal representation of their whole and fractional parts
- Strings are encoded verbatim
- Binary data is encoded as its Base64-encoded representation
- List values are encoded as a comma-separated list of the string representations of their entries
- Mapping values are encoded as a comma-separated list of `key=value` pairs, where `key` and `value` are the string representations of each of the mapping's key-value pairs

## Declaration

```yaml
fn::toString: value-to-encode
```

### Parameters

| Property          | Type   | Description                                                       |
|-------------------|--------|-------------------------------------------------------------------|
| `value-to-encode` | any    | The value to encode as a string.

### Returns

The string representation of the value.

