The COVID-19 pandemic has exposed the world's population to sudden challenges that elicited strong emotional reactions. Although investigations of responses to tragic one-off events exist, studies on the evolution of collective emotions during a pandemic are missing. We analyzed the digital traces of emotional expressions in tweets during five weeks after the start of outbreaks in 18 countries and six different languages. We observed an early strong upsurge of anxiety-related terms in all countries, which was stronger in countries with stronger increases in cases. Sadness terms rose and anger terms decreased around two weeks later, as social distancing measures were implemented. Positive emotions remained relatively stable. All emotions changed together with an increase in the stringency of measures during certain weeks of the outbreak. Our results show some of the most enduring changes in emotional expression observed in long periods of social media data. Words that frequently occurred in tweets suggest a shift in topics of conversation across all emotions, from political ones in 2019, to pandemic related issues during the outbreak, including everyday life changes, other people, and health. This kind of time-sensitive analyses of large-scale samples of emotional expression have the potential to inform mental health support and risk communication.