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

# Code

> Transform JSON in a JS sandbox.

Sandboxed JS. Receives `input` and readonly settings. Return a JSON-serializable value. Use `console.log` for debug output.

<h2 id="input">
  Input
</h2>

Inspector **Settings**. Empty-field rules for the Graph: [Previous nodes](/graph/previous-nodes). This inspector has no **Insert value**.

The script's `input` is the previous **Result** unless the Agent passes `input`.

| Field             | Required | Empty                  | Notes                                                         |
| ----------------- | -------- | ---------------------- | ------------------------------------------------------------- |
| **Source**        | Yes      | Default: sample script | The script. New nodes return `input`.                         |
| **Settings keys** | No       | —                      | Comma-separated Instance setting keys injected as `settings`. |

<h2 id="test">
  Run test
</h2>

**Test input (JSON or text)** and **Run test** execute against the selected Instance. Select an Instance to test code.

Output shows **Result** and **Console**. Failures show **Code failed** or **Code test failed**.

**View results** on the node also has a **Console** for `console.log` during a Graph Run.

<h2 id="output">
  Output
</h2>

On the next node, **Previous nodes** lists **`Code`: Result** (`{{Code.text}}` while the name is unique).

| Output  | In menu | Type | Next node gets                                                     |
| ------- | ------- | ---- | ------------------------------------------------------------------ |
| Result  | Yes     | Text | The script's return value, as JSON text (a string stays a string). |
| Console | No      | —    | `console.log` on **View results**. Not in Previous nodes.          |
