> For the complete documentation index, see [llms.txt](https://docs.zerowork.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zerowork.io/using-zerowork/using-building-blocks/dynamic-inputs/code-in-inputs.md).

# Code in Inputs

Use `${...}` for an expression and `$${...}` for a code block. Expressions insert their result. Code blocks run full code and must `return` a value to insert. All code runs locally on your device.

***

#### **Using `${...}` (expression)**

**Examples**

* "This is my secret password stored locally: ${`await zw.deviceStorage.get("password")`}"
* "This is my random number: ${`Math.random()`}"
* "This is my formatted input ${`"{id: 1234, name: Country Code}".trim().toUpperCase()`} \
  ⚠️ **Note**: table/variable references like `{id: 1234, name: Country Code}` are **not** code; they’re replaced with their values. If you need that value **as a string** inside code, wrap it in quotes (as above) or read it with `zw.getRef`: ${`(await zw.getRef({ ref_id: 1234, name: "Country Code" })).trim().toUpperCase()`}".

***

#### **Using `$${...}` (code block)**

**Examples:**

* "This is a value returned from an API: $${

  ```
  import axios from "axios"; // any import auto-installs locally
  const res = await axios.get("https://mydomain.com/my/api/url");
  return res.data;
  ```

&#x20;       }."

* "This is my input with more complex formatting: $${

  ```
  const fullAddress = await zw.getRef(ref_id: 1234, name: "Address" });
  const splitValues = fullAddress.split("country code: ");
  const countryCode = splitValues[1];

  if (!countryCode) {
    await zw.log({ message: "no country code", status: "warning" });
    return "unknown";
  }

  return countryCode.toUpperCase().trim();
  ```

  }."

***

<figure><img src="/files/Fc37E0prMkxKxrHfhjr1" alt=""><figcaption></figcaption></figure>
