AVADA logo
Published on

How to Convert String to JSON Fomat in Shopify

352 words2 min read
  • Name

In previous post, I have provide you details information about Additional filters, more specifically is Liquid Highlight. Therefor, to help you understand more about Addtional Filters, in this article, you will be shown on how to convert a string into JSON format in Shopify.

How to convert a string into JSON format in Shopify

Introduction {#introduction}

As you might not know about, Liquid JSON is an additional filter in Shopify. Besides dates, defaults, format or highlight, Liquid JSON is considered as one of the most extra filters in Shopify.

How to convert a string into JSON format in Shopify {#how-convert-string-into-json-format-shopify}


var content = {{ pages.page-handle.content | json }};


var content = "\u003Cp\u003E\u003Cstrong\u003EYou made it! Congratulations on starting your own e-commerce store!\u003C/strong\u003E\u003C/p\u003E\n\u003Cp\u003EThis is your shop\u0026#8217;s \u003Cstrong\u003Efrontpage\u003C/strong\u003E, and it\u0026#8217;s the first thing your customers will see when they arrive. You\u0026#8217;ll be able to organize and style this page however you like.\u003C/p\u003E\n\u003Cp\u003E\u003Cstrong\u003ETo get started adding products to your shop, head over to the \u003Ca href=\"/admin\"\u003EAdmin Area\u003C/a\u003E.\u003C/strong\u003E\u003C/p\u003E\n\u003Cp\u003EEnjoy the software,  \u003Cbr /\u003E\nYour Shopify Team.\u003C/p\u003E";

Take note that it is unnecessary to wrap those Liquid outputs in the quotations since the JSON filter will add them to. This filter also escapes quotes as need inside those outputs.

In addition, it also uses to make your Liquid objects readable by JavaScript.

var json_product = {{ collections.featured.products.first | json }};
var json_cart = {{ cart | json }};

Product inventory and JSON filter {#product-inventory-json-filter}

In fact, JSON filter does not output those values for inventory_quantity as well as inventory_policy fields for Shopify stores launched by Dec 5, 2017. Those fields will be deprecated to aid in eliminating both bots and crawlers from getting the inventory quantities for stores retrieved.


As you can see, Liquid JSON plays an important role in develop additional filters. We hope this post on how to convert a string into JSON format in Shopify will broaden your knowledge about additional filters in Shopify.

Don't have a Shopify store?

Get your free trial here -->x

Exclusive Offer: Shopify Deal for PageFly Audience

Start Your Online Business with Shopify 12 Day Free Trial + Pay Only 1$ For Your First Month