Encoding template functions
These template functions encode, decode, and hash data. Use them to turn bytes into readable text, generate checksums, or prepare data for APIs that expect a specific encoding.
Home Assistant extends the Jinja2 template engine with many custom functions, filters, and tests. Each function on this page has its own page with detailed descriptions, parameters, and practical examples.
New to templates? Start with the templating documentation to learn the basics.
-
Decode from base64
base64_decodeDecodes a base64-encoded string. -
Encode to base64
base64_encodeEncodes a string or bytes to a base64 string. -
Decode hex string to bytes
from_hexDecodes a hexadecimal string into bytes. -
MD5 hash
md5Calculates the MD5 hash of a string. -
Pack value to bytes
packPacks a value into bytes using a Python struct format string. -
SHA1 hash
sha1Calculates the SHA1 hash of a string. -
SHA256 hash
sha256Calculates the SHA256 hash of a string. -
SHA512 hash
sha512Calculates the SHA512 hash of a string. -
Unpack bytes to value
unpackUnpacks bytes into a value using a Python struct format string.