For example the template just outputs JSON, which breaks when Craft's devMode logging is added.

  • 1
    I'm not aware of any way to disable the debugging output from the template, but if you use the header tag to explicitly set the document's content type to JSON, Craft wont output the debug data: {% header "Content-Type: application/json" %} Commented Mar 5, 2015 at 16:16
  • Thanks Mats - worked fine. Do you want to create an answer so I can mark it as accepted?
    – Russ Back
    Commented Mar 6, 2015 at 12:15
  • That's great – I added an answer, thanks for following up. Commented Mar 6, 2015 at 12:28

2 Answers 2


You can't disable the debugging output using Twig/templates.

However, Craft will only render the debug data if your document' Content-type header is either "text/html" or "application/xhtml+xml" (source).

This means that if you're outputting JSON, you can set the template's Content-type to "application/json" (using Craft's header tag), preventing Craft from dumping the debug data to the response:

{% header "Content-Type: application/json" %}

You can create a simple plugin with an init() method like so:

public function init()

That will prevent the extra logging and profiling information to be output in the browser's console when devMode is enabled.

  • Thanks Brad - good to know. Setting the Content-Type was enough in the end, at least for this particular scenario.
    – Russ Back
    Commented Mar 6, 2015 at 12:15
  • I putt this on github if people are feeling lazy: github.com/crswll/silence Commented Mar 21, 2015 at 1:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.