# General Translation React SDKs (gt-react, gt-next, gt-react-native): decodeVars
URL: https://generaltranslation.com/en-US/docs/react/reference/functions/decode-vars.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Expand variables encoded by declareVar back into their values. API reference for decodeVars.

The `decodeVars` function extracts the original values from strings that contain [`declareVar`](/docs/react/reference/functions/declare-var) markers. Because [`declareVar`](/docs/react/reference/functions/declare-var) adds ICU-compatible markers to source text, those markers can interfere with string-processing logic — `decodeVars` removes them.

*Available in `gt-react`, `gt-next`, `gt-tanstack-start`, and `gt-react-native`.*

## Overview [#overview]

Pass a string containing [`declareVar`](/docs/react/reference/functions/declare-var) markers, and `decodeVars` returns it with the original values in place.

```tsx
function getGreeting({ name }) {
  const greeting = 'Hello, ' + declareVar(name);
  // "Hello, {_gt_, select, other {Brian}}"

  return decodeVars(greeting);
  // "Hello, Brian" — as if declareVar was never used
}
```

*Note: `decodeVars` only affects source strings that contain [`declareVar`](/docs/react/reference/functions/declare-var) markers. It has no effect on translated strings, and is not a general ICU MessageFormat parser.*

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

`decodeVars` targets the ICU MessageFormat patterns created by [`declareVar`](/docs/react/reference/functions/declare-var), interpolating each `_gt_` variable back to its original value while preserving other content exactly. Use it when existing string-manipulation logic needs to run on a string that contains variable markers.

## Parameters [#parameters]

| Parameter | Description | Type | Optional | Default |
| --- | --- | --- | --- | --- |
| [`icuString`](#icu-string) | A string containing ICU markers from [`declareVar`](/docs/react/reference/functions/declare-var) calls. | `string` | No | — |

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

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

A string that contains ICU markers produced by [`declareVar`](/docs/react/reference/functions/declare-var).

## Returns [#returns]

**Type** `string`

The string with ICU markers removed, containing the original variable values.

## Examples [#examples]

*Examples import from `gt-react`; import from your framework's package instead.*

```tsx title="BasicUsage.tsx"
import { declareVar, decodeVars } from 'gt-react';

const encodedVar = declareVar(name);
// "{_gt_, select, other {Alice}}"
const decodedVar = decodeVars(encodedVar);
// "Alice"
```

```tsx title="MultipleVariables.tsx"
import { declareVar, decodeVars } from 'gt-react';

const name1 = 'Alice';
const name2 = 'Bob';
const encodedVar =
  'Hello, ' + declareVar(name1) + '! My name is ' + declareVar(name2);
// "Hello, {_gt_, select, other {Alice}}! My name is {_gt_, select, other {Bob}}"

const decodedVar = decodeVars(encodedVar);
// "Hello, Alice! My name is Bob"
```

## Notes [#notes]

- Use `decodeVars` only on strings that contain [`declareVar`](/docs/react/reference/functions/declare-var) markers.
- It targets the ICU patterns created by [`declareVar`](/docs/react/reference/functions/declare-var) and should not be used on arbitrary ICU strings.
- It does not affect translation processing — it only removes markers for string manipulation.

## Sitemap

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