> ## 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.

# Wordcount

# \$wordCount

The `$wordCount` operator counts the number of words in a string.

## Input

* A single string value

## Output

* The number of words in the input string

## Examples

### Count Words in Sentence

```json theme={null}
{
  "$wordCount": [
    "Hello world this is a test"
  ]
}
```

Result: `6`

### Count Words in Single Word

```json theme={null}
{
  "$wordCount": [
    "Hello"
  ]
}
```

Result: `1`

### Count Words in Empty String

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

Result: `0`

### Field Value

```json theme={null}
{
  "$wordCount": [
    {
      "$input": "text"
    }
  ]
}
```

Result: The number of words in the text field
