How to Convert String to JSON Fomat in Shopify

Updated: August 09, 2021


Drive 20-40% of your revenue with AVADA
avada email marketing

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


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


var 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

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.

Recommend for you
Image Description
SMS, Email Marketing Automation

Top rated Marketing automation for Shopify stores

Learn more
Image Description
SEO Suite

Auto-optimize website elements and structure in one-click.

Learn more
Boost Sales [Free]

Boost sales: Sales Pop, Trust badges, Countdown timer, more

Learn more
Image Description
Photo Reviews [Free]

Use photo reviews to boost sales

Learn more


Stay in the know

Get special offers on the latest news from AVADA.

40k subscribers has been joined!

Earn $10 in reward now!

go up