Skip to content

Instantly share code, notes, and snippets.

@ConduciveMammal
Created November 13, 2025 13:21
Show Gist options
  • Select an option

  • Save ConduciveMammal/8973a3f9935486522b7290ae9b43a7f7 to your computer and use it in GitHub Desktop.

Select an option

Save ConduciveMammal/8973a3f9935486522b7290ae9b43a7f7 to your computer and use it in GitHub Desktop.
Liquid Debug Snippet
{%- doc -%}
Outputs the provided Liquid value to the browser console for debugging.
@param {string} [title] - Optional label for the instance
@param this - The instance content to debug
@param {boolean} [json] - If true, also logs a parsed JSON version of the instance
@example
{% render 'debug', this: shop.metafields.services.title, json: true %}
{% render 'debug', this: product.images, json: false %}
{%- enddoc -%}
{%- liquid
if title != blank
assign label = title
else
assign label = 'DEBUG'
endif
-%}
<script>
console.group('%c{{ label }} Debugging', 'color: orange; font-weight: bold;');
{% if json %}
console.log('%cJSON:', 'color: #00CC66; font-weight: bold', JSON.parse('{{ this | json }}'))
{% endif %}
console.log('%cRaw:', 'color: #009933; font-weight: bold', '{{ this }}')
console.groupEnd();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment