Skip to content

Instantly share code, notes, and snippets.

Created April 20, 2016 10:56
What would you like to do?
Debugging Objects in Shopify Templates
<script>console.log({{ product | json }});</script>
Copy link

Thiritin commented Sep 3, 2021

Thank you very much!

Copy link

linus-komnick commented Oct 26, 2021

Thx! It works. But not everywhere. E.g. in product-template.liquid I was able to get the log when inserting it above the div with the product description:

        <script>console.log({{ product | json }});</script>

        <div class="product-single__description rte">
          {{ product.description }}

Copy link

Henry31 commented Apr 21, 2022

Thanks a lot!

Copy link

ru4ert commented May 2, 2022

What are you doing when you have larger objects and JSON isn't allowed?

json not allowed for this object

Copy link

I accessed the properties of the object until it allowed me to do it in my last project.

For example...

<script>console.log({{ product.images | json }});</script>

When I first posted this product supported JSON, but I guess now it doesn't.

This snippet was a quick way of me examining the object without looking at the docs, maybe not quite as useful now.

Copy link

gdSuhail commented Jun 2, 2022


Copy link

Good job

Copy link

thanks so much! 🙇 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment