Magento 2: Return JSON, XML, HTML & Raw Text Data Response from Controller

This article shows how you can return JSON data, XML data, HTML data, or Raw Text data from any Controller class in Magento 2. Generally, in the Magento2 controller’s execute() function, we see the redirect or forwarding call which redirects to the specified URL page. However, we might sometime need to return the JSON format … Read more