# gt-node: General Translation Node.js SDK: decodeVars
URL: https://generaltranslation.com/en-US/docs/node/reference/functions/decode-vars.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Interpolate General Translation declareVar variables back into a string. API reference for decodeVars.

Interpolates the `_gt_` variables that [`declareVar`](/docs/node/reference/functions/declare-var) encoded into an ICU string, replacing each encoded `select` expression with its value.

## Overview [#overview]

Call `decodeVars` with an ICU string that contains [`declareVar`](/docs/node/reference/functions/declare-var) output. It returns the string with each encoded variable replaced by its `other` value. Strings without any `_gt_` variables are returned unchanged.

```ts
import { decodeVars, declareVar } from 'gt-node';

const encoded = 'Hi ' + declareVar('Brian') + ', my name is {name}';
const decoded = decodeVars(encoded);
console.log(decoded); // 'Hi Brian, my name is {name}'
```

Signature:

```ts
decodeVars(icuString: string): string
```

## How it works [#how-it-works]

- **Targeted interpolation.** Only `_gt_` variables produced by [`declareVar`](/docs/node/reference/functions/declare-var) are interpolated; other ICU placeholders (such as `{name}`) are left intact.
- **Passthrough.** When the string contains no `_gt_` identifier, it is returned unchanged.

## Parameters [#parameters]

| Parameter | Description | Type | Optional | Default |
| --- | --- | --- | --- | --- |
| [`icuString`](#icu-string) | The ICU string to interpolate. | `string` | No | — |

### `icuString` [#icu-string]

**Type** `string` · **Required**

An ICU string that may contain `_gt_` variables encoded by [`declareVar`](/docs/node/reference/functions/declare-var).

## Returns [#returns]

**Type** `string`

The string with encoded `_gt_` variables replaced by their values, or the input unchanged when there are none.

## Examples [#examples]

```ts
import { decodeVars, declareVar } from 'gt-node';

const encoded = 'Hi ' + declareVar('Brian') + ', my name is {name}';
console.log(decodeVars(encoded)); // 'Hi Brian, my name is {name}'
```

## Notes [#notes]

- `decodeVars` complements [`declareVar`](/docs/node/reference/functions/declare-var); it only affects `_gt_` variables.

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
