You can use expressions to sophisticate the customization of your templates.

Expressions must be surrounded by double curly braces {{ and }}.

For example, you can use expressions to adjust the duration of an element based on the value of a variable plus a number of seconds.

{
	"comment": "Expressions example",
	"resolution": "full-hd",
    "variables": {
        "text_element_duration": 10
    },
	"scenes": [
		{
			"background-color": "{{bgColor}}",
			"elements": [
				{
					"type": "text",
					"style": "005",
					"text": "{{message1}}",
					"duration": "{{text_element_duration}}"
				},
                {
                    "type": "audio",
                    "src": "https://www.json2video.com/audio/example.mp3",
                    "duration": "{{text_element_duration + 5}}"
                }
			]
		}
	]
}

In this example, the text element will be displayed for 10 seconds and the audio element will play for 15 seconds.

Examples of expressions

Here are some examples of expressions that you can use in your templates: