What are the potential drawbacks of using <pre> tags for formatting JSON output in PHP?

Using <pre> tags for formatting JSON output in PHP can lead to potential security vulnerabilities, as it exposes raw JSON data to users, which could include sensitive information. To mitigate this risk, it's recommended to encode the JSON data before outputting it to the user. This can be achieved by using the htmlentities function in PHP to escape special characters and prevent any potential XSS attacks.

$jsonData = json_encode($data);
echo &#039;&lt;pre&gt;&#039; . htmlentities($jsonData) . &#039;&lt;/pre&gt;&#039;;