# gt-node: General Translation Node.js SDK: decodeMsg URL: https://generaltranslation.com/en-GB/docs/node/reference/functions/decode-msg.mdx --- title: decodeMsg description: Recover the original message string from a General Translation-encoded message. API reference for decodeMsg. --- Extracts the original interpolated message string from a value encoded by [`msg`](/docs/node/reference/functions/msg). Use it when you need the human-readable content of an encoded message rather than its translation. ## Overview [#overview] Call `decodeMsg` with an encoded message. It returns the content before the encoded options (everything up to the last colon). If the input has no colon separator, it is returned unchanged. ```ts import { msg, decodeMsg } from 'gt-node'; const encoded = msg('Hello, {name}!', { name: 'Brian' }); console.log(decodeMsg(encoded)); // 'Hello, Brian!' ``` Signature: ```ts decodeMsg(encodedMsg: string): string; decodeMsg(encodedMsg: T): T; ``` ## How it works [#how-it-works] * **Separator split.** An encoded message has the form `interpolatedContent:encodedOptions`. `decodeMsg` returns the content before the last colon. * **Passthrough.** When the value has no colon, or is `null`/`undefined`, it is returned unchanged. ## Parameters [#parameters] | Parameter | Description | Type | Optional | Default | | ---------------------------- | ------------------------------ | ----------------------------- | -------- | ------- | | [`encodedMsg`](#encoded-msg) | The encoded message to decode. | `string \| null \| undefined` | No | — | ### `encodedMsg` [#encoded-msg] **Type** `string | null | undefined` · **Required** The message to decode, typically a value returned by [`msg`](/docs/node/reference/functions/msg). ## Returns [#returns] **Type** `string | null | undefined` The decoded message content, or the input unchanged when it cannot be decoded. ## Examples [#examples] ```ts import { msg, decodeMsg } from 'gt-node'; const encoded = msg('Welcome, {name}!', { name: 'Alice' }); console.log(decodeMsg(encoded)); // 'Welcome, Alice!' console.log(decodeMsg('Plain text')); // 'Plain text' (no options to strip) ``` ## Notes [#notes] * `decodeMsg` returns source content, not a translation. Use [`getMessages`](/docs/node/reference/functions/get-messages) to resolve the translation. * To read the encoded options rather than the content, use [`decodeOptions`](/docs/node/reference/functions/decode-options).