random
Generates random values — strings, numbers, alphanumeric codes, or floating-point numbers. Useful for creating unique identifiers, random codes, and test data.
{% assign code = "alphanumeric" | random: 8 %}
{% log code %}Syntax
{{ type | random }}
{{ type | random: length }}
{{ type | random: length, downcase }}Modes
Alphanumeric string
Generates a random string of letters and digits.
{{ "alphanumeric" | random: 8 }}length
Number of characters (1–20, default: 5)
downcase
Set to true for lowercase only
{% assign code = "alphanumeric" | random: 10 %}
{% log code %}Output: aB3xK9mP2n
{% assign code = "alphanumeric" | random: 6, true %}
{% log code %}Output: k3m8p2
Number
Generates a random integer with the specified number of digits.
length
Number of digits (1–20, default: 5)
Output: 7284
String (letters only)
Generates a random string of letters only (no digits).
length
Number of characters (1–20, default: 5)
downcase
Set to true for lowercase only
Output: KmPxBnTr
Float / Decimal
Generates a random floating-point number within a range.
min
Minimum value (default: 0)
max
Maximum value (default: 1)
Output: 47.382917
Examples
Generate a unique order reference:
Generate a discount code:
Generate a random verification PIN:
Generate a random price for testing:
Notes
Maximum length for strings and numbers is 20 characters/digits
"float"and"decimal"are interchangeable — both generate floating-point numbersRandom values are not cryptographically secure — do not use for passwords or security tokens
For secure hashing, use
hmac_sha256orsha1instead
Last updated