Skip to main content
The Jsonnet element embeds a Jsonnet template in your Elemental document. Jsonnet is a data templating language that generates JSON, so it suits structured content built programmatically. The type value is "jsonnet". When to use:
  • Generate dynamic JSON structures based on data
  • Create reusable template logic with functions and variables
  • Build complex nested objects programmatically
  • Avoid repetitive JSON structures
  • Generate locale-specific content programmatically
Jsonnet is an advanced feature and requires knowing its syntax. For simple content, use with Handlebars variables instead.
Basic example
Fields
string
required
The Jsonnet template code. A string of valid Jsonnet, evaluated to produce JSON. The template reaches message data through Jsonnet’s standard variable access.
object
Region-specific Jsonnet templates. Keys are locale codes (e.g., "es", "fr"), and each value is the Jsonnet template for that locale. See the .
string[]
An array of channel names. The Jsonnet element renders only for the listed channels. See .
Jsonnet language basics Jsonnet extends JSON with:
  • Variables: local name = "Sarah Bennett";
  • Functions: local greet(name) = "Hello " + name;
  • Object composition: Merge objects with +
  • Conditionals: if condition then value1 else value2
  • Loops: [x * 2 for x in [1, 2, 3]]
  • Imports: local lib = import "lib.jsonnet";
For complete Jsonnet language documentation, see the official Jsonnet documentation.
Examples and variants Simple object generation Generate a simple JSON object:
Output:
Using functions Create reusable functions:
Output:
Conditional content Generate different content based on conditions:
Output:
Localized templates Provide different Jsonnet templates for different locales:
Complex nested structures Build complex nested objects:
Output:
Jsonnet templates are evaluated at render time. A syntax or runtime error fails the whole notification render. Test your templates before deploying.
Channel support
  • Email: ✅ Full support
  • Push: ✅ Supported (JSON output can be used in push payloads)
  • SMS: ⚠️ Limited support (JSON output may need to be stringified)
  • Inbox: ✅ Full support
Additional resources