{"title":"decrypt - Liquid Filter Reference","slug":"decrypt-filter-reference","url":"https://support.storeconnect.com/articles/decrypt-filter-reference","url_markdown":"https://support.storeconnect.com/articles/decrypt-filter-reference.md","subtitle":null,"summary":"Decrypts a value previously encrypted with the encrypt filter. Without a salt, decryption only works within the same session. Returns nil on error with specific messages for each failure case.","type":"Developer_Documentation","video_url":"","keywords":"liquid, filters, decrypt, security, storeconnect","last_modified":"2026-10-08T21:27:56+0000","body_markdown":"## Description\n\nDecrypts a value that was previously encrypted using the [encrypt](encrypt-filter-reference) filter. The `salt` option, if used during encryption, must be provided here with the same value. Errors are logged to the Web Console rather than surfaced to the storefront.\n\n| Property | Value |\n|----------|-------|\n| **Return Type** | string, integer, float, boolean, array, or hash (matches original input type) |\n| **Error return** | `nil` (not an empty string) |\n| **Category** | text |\n\n## Options\n\n| Option | Description |\n|--------|-------------|\n| `salt` | An optional salt string used as part of the decryption key. Must match the `salt` used when the value was encrypted. **If omitted, the current session ID is used — the value must have been encrypted in the same session.** |\n\n## Examples\n\n**Decrypt a previously encrypted value:**\n\n\n```liquid\n\n{{ encrypted_value | decrypt: salt: \"my-secret-salt\" }}\n```\n\n\n**Round-trip example — encrypt then decrypt:**\n\n\n```liquid\n\n{% assign encrypted = \"hello world\" | encrypt: salt: \"my-salt\" %}\n{% assign decrypted = encrypted | decrypt: salt: \"my-salt\" %}\n{{ decrypted }}\n```\n\n\n**Output:** `hello world`\n\n**Decrypt an encrypted array:**\n\n\n```liquid\n\n{% assign original = \"one,two,three\" | split: \",\" %}\n{% assign encrypted = original | encrypt: salt: \"list-salt\" %}\n{% assign decrypted = encrypted | decrypt: salt: \"list-salt\" %}\n{% for item in decrypted %}{{ item }}{% endfor %}\n```\n\n\n## Error handling\n\nIf decryption fails, the error is written to the Web Console and `nil` is returned. The specific error and message depends on the cause:\n\n| Cause | Console message |\n|-------|----------------|\n| No encryption salt configured | `No encryption salt found. Cannot encrypt or decrypt data.` |\n| Token structure is invalid | `Decrypted token is not valid` |\n| Token contains an unsupported type | `Decrypted token has unsupported type {type}` |\n| Wrong salt or corrupted token | Returns `nil` silently (no console message) |\n\nCheck the Web Console and verify the `salt` value matches what was used during encryption."}