diff --git a/netbox_config_diff/templates/netbox_config_diff/configcompliance/data.html b/netbox_config_diff/templates/netbox_config_diff/configcompliance/data.html
index 5c20e42..e845774 100644
--- a/netbox_config_diff/templates/netbox_config_diff/configcompliance/data.html
+++ b/netbox_config_diff/templates/netbox_config_diff/configcompliance/data.html
@@ -70,7 +70,7 @@
stickyFileHeaders: false,
drawFileList: false,
};
- const jsonDiff = `{{ instance.diff|safe }}`;
+ const jsonDiff = `{{ instance.diff|escapejs|safe }}`;
var targetElement = document.getElementById('diffElement');
var diff2htmlUi = new Diff2HtmlUI(targetElement, jsonDiff, configuration);
diff2htmlUi.draw();
diff --git a/netbox_config_diff/templates/netbox_config_diff/inc/diff.html b/netbox_config_diff/templates/netbox_config_diff/inc/diff.html
index bc1864a..7f5130e 100644
--- a/netbox_config_diff/templates/netbox_config_diff/inc/diff.html
+++ b/netbox_config_diff/templates/netbox_config_diff/inc/diff.html
@@ -17,7 +17,7 @@
stickyFileHeaders: false,
drawFileList: false,
};
- const jsonDiff = `{{ data|safe }}`;
+ const jsonDiff = `{{ data|escapejs|safe }}`;
var targetElement = document.getElementById('{{ device_name }}-diffElement');
var diff2htmlUi = new Diff2HtmlUI(targetElement, jsonDiff, configuration);
diff2htmlUi.draw();