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

# Tostring

# \$toString

The `$toString` operator converts a value to a string, with optional formatting for dates.

## Input

* An array containing one or two values: the value to convert and an optional format string (for dates)

## Output

* The string representation of the input value

## Examples

### Basic Conversion

```json theme={null}
{
  "$toString": [
    42
  ]
}
```

Result: `"42"`

### Date Formatting

```json theme={null}
{
  "$toString": [
    {
      "$toDate": ["2023-01-15T10:30:00Z"]
    },
    "2006-01-02 15:04:05"
  ]
}
```

Result: `"2023-01-15 10:30:00"`

### Field Value

```json theme={null}
{
  "$toString": [
    {
      "$input": "number_value"
    }
  ]
}
```

Result: The string representation of the number\_value field
