decrypt - Liquid Filter Reference
On this page
Description
Decrypts a value that was previously encrypted using the encrypt 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.
| Property | Value |
|---|---|
| Return Type | string, integer, float, boolean, array, or hash (matches original input type) |
| Error return | nil (not an empty string) |
| Category | text |
Options
| Option | Description |
|---|---|
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. |
Examples
Decrypt a previously encrypted value:
liquid
{{ encrypted_value | decrypt: salt: "my-secret-salt" }}
Round-trip example — encrypt then decrypt:
liquid
{% assign encrypted = "hello world" | encrypt: salt: "my-salt" %}
{% assign decrypted = encrypted | decrypt: salt: "my-salt" %}
{{ decrypted }}
Output: hello world
Decrypt an encrypted array:
liquid
{% assign original = "one,two,three" | split: "," %}
{% assign encrypted = original | encrypt: salt: "list-salt" %}
{% assign decrypted = encrypted | decrypt: salt: "list-salt" %}
{% for item in decrypted %}{{ item }}{% endfor %}
Error handling
If decryption fails, the error is written to the Web Console and nil is returned. The specific error and message depends on the cause:
| Cause | Console message |
|---|---|
| No encryption salt configured | No encryption salt found. Cannot encrypt or decrypt data. |
| Token structure is invalid | Decrypted token is not valid |
| Token contains an unsupported type | Decrypted token has unsupported type {type} |
| Wrong salt or corrupted token | Returns nil silently (no console message) |
Check the Web Console and verify the salt value matches what was used during encryption.