diff --git a/roles/matrix/templates/homeserver.yaml.j2 b/roles/matrix/templates/homeserver.yaml.j2
index aa6d87219a288c308aa92f1cf21152883510bf23..6bcedd948b84fc20bad1a7de2afc081dd4c1594d 100644
--- a/roles/matrix/templates/homeserver.yaml.j2
+++ b/roles/matrix/templates/homeserver.yaml.j2
@@ -109,7 +109,7 @@ federation_metrics_domains:
 # Auto-join new users to rooms
 auto_join_rooms:
 {% for room in vault_matrix_secrets.auto_join_rooms %}
-  - {{ room | quote }}
+  - {{ room | to_json }}
 {% endfor %}
 autocreate_auto_join_rooms: false
 auto_join_mxid_localpart: mjolnir
diff --git a/roles/matrix/templates/mjolnir.yaml.j2 b/roles/matrix/templates/mjolnir.yaml.j2
index 1eeebefb96f100e5bc3d337310431e1efa5c66e5..7f1a22ddf8699a3d45359091dca31e67680b5be0 100644
--- a/roles/matrix/templates/mjolnir.yaml.j2
+++ b/roles/matrix/templates/mjolnir.yaml.j2
@@ -164,7 +164,7 @@ protections:
     #  - https://regexone.com/
     words:
 {% for word in vault_matrix_secrets.mjolnir_badwords %}
-      - {{ word | quote }}
+      - {{ word | to_json }}
 {% endfor %}
 
     # For how long (in minutes) the user is "new" to the WordList plugin.