> For the complete documentation index, see [llms.txt](https://docs.n8n.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.n8n.io/build/work-with-data/transform-data/expression-reference/root.md).

# Root

## **`$()`** <a href="#dollar" id="dollar"></a>

**Description:** Returns the data of the specified node

**Syntax:** $(nodeName)

**Returns:** NodeData

**Source:** Custom n8n functionality

**Parameters:**

* `nodeName` (String) - The name of the node to retrieve data for

## **`$binary`** <a href="#dollarbinary" id="dollarbinary"></a>

**Description:** Returns any binary input data to the current node, for the current item. Shorthand for `$input.item.binary`.

**Syntax:** **`$binary`**

**Returns:** Array

**Source:** Custom n8n functionality

## **`$execution`** <a href="#dollarexecution" id="dollarexecution"></a>

**Description:** Retrieve or set metadata for the current execution

**Syntax:** **`$execution`**

**Returns:** ExecData

**Source:** Custom n8n functionality

## **`$fromAI()`** <a href="#dollarfromai" id="dollarfromai"></a>

**Description:** Use when a large language model should provide the value of a node parameter. Consider providing a description for better results.

**Syntax:** $fromAI(key, description?, type?, defaultValue?)

**Returns:** any

**Source:** Custom n8n functionality

**Parameters:**

* `key` (String) - The name of the field to fetch. May only contain letters, numbers, underscores and hyphens.
* `description` (String) - optional - Use to give the model more context on exactly what it should return
* `type` (String) - optional - The type of the value to return. One of `string`, `number`, `boolean`, `json`, `date`, `datetime`. Defaults to `string`.
* `defaultValue` (any) - optional - A value to use if the model doesn’t return the key

**Examples:**

```javascript
// Ask the model to provide a name, and use it here
$fromAI('name')
```

```javascript
// Ask the model to provide the age of the person (as a number with a default value of 18), and use it here
$fromAI('age', 'The age of the person', 'number', 18)
```

```javascript
// Ask the model to provide a boolean signifying whether the person is a student (with default value false), and use it here
$fromAI('isStudent', 'Is the person a student', 'boolean', false)
```

## **`$if()`** <a href="#dollarif" id="dollarif"></a>

**Description:** Returns one of two values depending on the `condition`. Similar to the `?` operator in JavaScript.

**Syntax:** $if(condition, valueIfTrue, valueIfFalse)

**Returns:** any

**Source:** Custom n8n functionality

**Parameters:**

* `condition` (Boolean) - The check to make. Should evaluate to either `true` or `false`
* `valueIfTrue` (any) - The value to return if the condition is true
* `valueIfFalse` (any) - The value to return if the condition is false

**Examples:**

```javascript
// Return "Good day" if time is before 5pm, otherwise "Good evening"
$if($now.hour < 17, "Good day", "Good evening")
```

```javascript
// $if() calls can be combined:
// Return "Good morning" if time is before 10am, "Good day" it's before 5pm, otherwise "Good evening"
$if($now.hour < 10, "Good morning", $if($now.hour < 17, "Good day", "Good evening"))
```

## **`$ifEmpty()`** <a href="#dollarifempty" id="dollarifempty"></a>

**Description:** Returns the first parameter if it isn’t empty, otherwise returns the second parameter. The following count as empty: `””`, `[]`, `{}`, `null`, `undefined`

**Syntax:** $ifEmpty(value, valueIfEmpty)

**Returns:** any

**Source:** Custom n8n functionality

**Parameters:**

* `value` (any) - The value to return, provided it isn’t empty
* `valueIfEmpty` (any) - What to return if `value` is empty

**Examples:**

```javascript
"Hi " + $ifEmpty(name, "there") // e.g. "Hi Nathan" or "Hi there"
```

## **`$input`** <a href="#dollarinput" id="dollarinput"></a>

**Description:** The input data of the current node

**Syntax:** **`$input`**

**Returns:** NodeData

**Source:** Custom n8n functionality

## **`$itemIndex`** <a href="#dollaritemindex" id="dollaritemindex"></a>

**Description:** The position of the item currently being processed in the list of input items

**Syntax:** **`$itemIndex`**

**Returns:** Number

**Source:** Custom n8n functionality

## **`$jmespath()`** <a href="#dollarjmespath" id="dollarjmespath"></a>

**Description:** Extracts data from an object (or array of objects) using a \<a href=”/code/cookbook/jmespath/”>JMESPath expression. Useful for querying complex, nested objects. Returns `undefined` if the expression is invalid.

**Syntax:** $jmespath(obj, expression)

**Returns:** any

**Source:** Custom n8n functionality

**Parameters:**

* `obj` (Object|Array) - The Object or array of Objects to retrieve data from
* `expression` (String) - A \<a href=”[https://jmespath.org/examples.html”>JMESPath](https://jmespath.org/examples.html”>JMESPath) expression defining the data to retrieve from the object

**Examples:**

```javascript
data = {
  "people": [
    {
      "age": 20,
      "other": "foo",
      "name": "Bob"
    },
    {
      "age": 25,
      "other": "bar",
      "name": "Fred"
    },
    {
      "age": 30,
      "other": "baz",
      "name": "George"
    }
  ]
}

// Get all names, in an array
{{ $jmespath(data, '[*].name') }} //=> ["Bob", "Fred", "George"]

// Get the names and ages of everyone under 20
$jmespath(data, '[?age > `20`].[name, age]') //=> [ ["Fred",25], ["George",30] ]

// Get the name of the first person under 20
$jmespath($json.people, '[?age > `20`].name | [0]') //=> Fred
```

```javascript
data = {
    "reservations": [
      {
        "id": 1,
        "guests": [
          {
            "name": "Nathan",
            "requirements": {
              "room": "double",
              "meal": "vegetarian"
            }
          },
          {
            "name": "Meg",
            "requirements": {
              "room": "single"
            }
          }
        ]
      },
      {
        "id": 2,
        "guests": [
          {
            "name": "Lex",
            "requirements": {
              "room": "double"
            }
          }
        ]
      }
    ]
  }

// Get the names of all the guests in each reservation that require a double room
$jmespath(data, 'reservations[].guests[?requirements.room==`double`].name')
```

## **`$json`** <a href="#dollarjson" id="dollarjson"></a>

**Description:** Returns the JSON input data to the current node, for the current item. Shorthand for `$input.item.json`. [More info](/build/work-with-data/understand-n8ns-data-structure.md)

**Syntax:** **`$json`**

**Returns:** Object

**Source:** Custom n8n functionality

## **`$max()`** <a href="#dollarmax" id="dollarmax"></a>

**Description:** Returns the highest of the given numbers

**Syntax:** $max(num1, num2, …, numN)

**Returns:** Number

**Source:** Custom n8n functionality

**Parameters:**

* `num1` (Number) - The first number to compare
* `num2` (Number) - The second number to compare

## **`$min()`** <a href="#dollarmin" id="dollarmin"></a>

**Description:** Returns the lowest of the given numbers

**Syntax:** $min(num1, num2, …, numN)

**Returns:** Number

**Source:** Custom n8n functionality

**Parameters:**

* `num1` (Number) - The first number to compare
* `num2` (Number) - The second number to compare

## **`$nodeVersion`** <a href="#dollarnodeversion" id="dollarnodeversion"></a>

**Description:** The version of the current node (as displayed at the bottom of the nodes’s settings pane)

**Syntax:** **`$nodeVersion`**

**Returns:** String

**Source:** Custom n8n functionality

## **`$now`** <a href="#dollarnow" id="dollarnow"></a>

**Description:** A DateTime representing the current moment.

Uses the workflow’s time zone (which can be changed in the workflow settings).

**Syntax:** **`$now`**

**Returns:** DateTime

**Source:** Custom n8n functionality

## **`$pageCount`** <a href="#dollarpagecount" id="dollarpagecount"></a>

**Description:** The number of results pages the node has fetched. Only available in the ‘HTTP Request’ node.

**Syntax:** **`$pageCount`**

**Returns:** Number

**Source:** Custom n8n functionality

## **`$parameter`** <a href="#dollarparameter" id="dollarparameter"></a>

**Description:** The configuration settings of the current node. These are the parameters you fill out within the node’s UI (e.g. its operation).

**Syntax:** **`$parameter`**

**Returns:** NodeParams

**Source:** Custom n8n functionality

## **`$prevNode`** <a href="#dollarprevnode" id="dollarprevnode"></a>

**Description:** Information about the node that the current input came from.

When in a ‘Merge’ node, always uses the first input connector.

**Syntax:** **`$prevNode`**

**Returns:** PrevNodeData

**Source:** Custom n8n functionality

## **`$request`** <a href="#dollarrequest" id="dollarrequest"></a>

**Description:** The request object sent during the last run of the node. Only available in the ‘HTTP Request’ node.

**Syntax:** **`$request`**

**Returns:** Object

**Source:** Custom n8n functionality

## **`$response`** <a href="#dollarresponse" id="dollarresponse"></a>

**Description:** The response returned by the last HTTP call. Only available in the ‘HTTP Request’ node.

**Syntax:** **`$response`**

**Returns:** HTTPResponse

**Source:** Custom n8n functionality

## **`$runIndex`** <a href="#dollarrunindex" id="dollarrunindex"></a>

**Description:** The index of the current run of the current node execution. Starts at 0.

**Syntax:** **`$runIndex`**

**Returns:** Number

**Source:** Custom n8n functionality

## **`$secrets`** <a href="#dollarsecrets" id="dollarsecrets"></a>

**Description:** The secrets from an [external secrets vault](/deploy/host-n8n/configure-n8n/basic-configuration/use-environment-variables/external-secrets.md), if configured. Secret values are never displayed to the user. Only available in credential fields.

**Syntax:** **`$secrets`**

**Returns:** Object

**Source:** Custom n8n functionality

## **`$today`** <a href="#dollartoday" id="dollartoday"></a>

**Description:** A DateTime representing midnight at the start of the current day.

Uses the instance’s time zone (unless overridden in the workflow’s settings).

**Syntax:** **`$today`**

**Returns:** DateTime

**Source:** Custom n8n functionality

## **`$vars`** <a href="#dollarvars" id="dollarvars"></a>

**Description:** The [variables](/build/code-in-n8n/define-custom-variables.md) available to the workflow

**Syntax:** **`$vars`**

**Returns:** Object

**Source:** Custom n8n functionality

## **`$workflow`** <a href="#dollarworkflow" id="dollarworkflow"></a>

**Description:** Information about the current workflow

**Syntax:** **`$workflow`**

**Returns:** WorkflowData

**Source:** Custom n8n functionality
