The real value of the "json" nunjucks filter is in outputting data in the body of a script tag. As such, it must escape <!-- and </script> with \ in order to avoid accidentally closing the entire script tag. The result is thus not strictly JSON, but it is more useful than strict JSON in the context of an HTML template.