# "fromjson" Filter Stopped Working in Programmable Email Modules: "Invalid input for 'fromjson'"

**URL:** <https://community.hubspot.com/t/fromjson-filter-stopped-working-in-programmable-email-modules-invalid-input-for-fromjson/144317>\
**Category:** APIs & Integrations\
**Tags:** email\
**Created:** [December 22, 2025, 6:29pm UTC](https://community.hubspot.com/t/fromjson-filter-stopped-working-in-programmable-email-modules-invalid-input-for-fromjson/144317 "2025-12-22T18:29:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fordnichols](https://avatars.discourse-cdn.com/v4/letter/f/839c29/32.png) [@fordnichols](https://community.hubspot.com/u/fordnichols)\
**Post date:** [December 22, 2025, 6:29pm UTC](https://community.hubspot.com/t/fromjson-filter-stopped-working-in-programmable-email-modules-invalid-input-for-fromjson/144317/1 "2025-12-22T18:29:29Z")

</div>

Hi everyone,

I have a programmable email module that was working perfectly about 2 months ago, but now the “fromjson” usage fails validation with this error:

Invalid input for ‘fromjson’: input could not be converted to an object

I haven’t changed any code. Because of this I am unable to make changes because it won’t publish with validation errors.

**What I’m doing:** Using the fromjson filter to parse JSON data stored in a contact property for abandoned cart emails:

```auto
{% set cart_items_json = contact.cart_items %}
{% set cart_items = cart_items_json|fromjson %}
{% for item in cart_items %}
 <!-- display cart item -->
{% endfor %}

```

**The problem:**

- This worked fine 2 months ago
- Now getting validation errors when trying to save/publish
- The validator blocks fromjson even though it’s in a programmable email module
- When I bypass validation (undo + quick publish), the emails actually render correctly

**What I’ve tried:**

- Adding |safe filter
- Conditional checks
- Different syntax variations
- All still trigger validation errors

**Question:** Did HubSpot change validation rules recently? Is there a new approved way to parse JSON contact properties in programmable emails? This is blocking critical abandoned cart functionality.

---

<div class="post-metadata">

**Author:** ![SealaB](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sealab/32/88952_2.png) [@SealaB](https://community.hubspot.com/u/SealaB)\
**Post date:** [December 23, 2025, 1:50am UTC](https://community.hubspot.com/t/fromjson-filter-stopped-working-in-programmable-email-modules-invalid-input-for-fromjson/144317/2 "2025-12-23T01:50:02Z")

</div>

Hi @fordnichols, welcome to HubSpot’s Developer forums!

Right off the bat, I’m tagging in a couple of our top experts, [@Teun-SB](https://community.hubspot.com/t5/user/viewprofilepage/user-id/910607) and [@Anton-B](https://community.hubspot.com/t5/user/viewprofilepage/user-id/144634), to see if they have encountered this specific validation shift recently or have other workarounds for the fromjson filter behavior.

I will note, that I am not a developer, but here is what I’m hearing back from my AI deep dives:  
_The error “input could not be converted to an object” during validation often occurs because the validator interprets the contact.cart\_items property as null or undefined, whereas at runtime (when sending a real email), it has a value._

_To pass the validation check, you often need to provide a “fallback” string that is valid JSON so the filter has something to process even when the contact property is empty._

_Could you try updating your code to include a default value before the filter?_

> {% set cart\_items\_json = contact.cart\_items|default(‘[]’) %}  
> {% set cart\_items = cart\_items\_json|fromjson %}

_Or combined:_

> {% set cart\_items = (contact.cart\_items|default(‘[]’))|fromjson %}

_If the above doesn’t clear the error, it is possible the validator is seeing the data as “unsafe” (HTML escaped). Ensure the safe filter is applied before fromjson._

> {% set cart\_items = (contact.cart\_items|default(‘[]’)|safe)|fromjson %}

Again, please keep in mind that the above coding suggestions are **AI generated**.

[(HubL Filters - fromjson](https://developers.hubspot.com/docs/cms/hubl/filters#fromjson))  
_ **Pro tip:** _

\*\* I’ll also quickly point out that our **new Dev MCP** is like an AI code checker! \*\*  
**Check out t** [**his video**](https://youtu.be/y_ZxPFmnWTQ?si=Srjm8AklRS4MvXzt) to learn more about the tool!

---

<div class="post-metadata">

**Author:** ![amjadkhatri](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/amjadkhatri/32/79746_2.png) [@amjadkhatri](https://community.hubspot.com/u/amjadkhatri)\
**Post date:** [December 23, 2025, 6:15am UTC](https://community.hubspot.com/t/fromjson-filter-stopped-working-in-programmable-email-modules-invalid-input-for-fromjson/144317/3 "2025-12-23T06:15:01Z")

</div>

This is a really frustrating situation especially when your code worked fine before and now suddenly the validator is blocking you. What you are experiencing is not a code problem on your end but a change in how HubSpot’s validation engine handles the fromjson filter during the save/publish stage.

The root issue is that during validation, the contact property contact.cart\_items is being evaluated as null or undefined because there is no actual contact record loaded in that validation context. The fromjson filter cannot parse null or an empty string, so it throws the error even though your code would work perfectly fine when the email is actually sent to a real contact with cart data.

Here is what you need to do to fix this:

Add a default fallback value so the validator has valid JSON to work with during the validation pass. Change your code from this:

{% set cart\_items\_json = contact.cart\_items %}  
{% set cart\_items = cart\_items\_json|fromjson %}

To this:

{% set cart\_items = (contact.cart\_items|default(‘[]’))|fromjson %}

This tells HubSpot to use an empty JSON array [] as the default value if contact.cart\_items is null or missing. The validator will now have valid JSON to parse, so it will stop throwing the error. When the email goes out to real contacts who have cart\_items populated, it will use the actual data instead of the default.

If you need to add the safe filter as well for any HTML content in your JSON, you can combine them like this:

{% set cart\_items = (contact.cart\_items|default(‘[]’)|safe)|fromjson %}

After you make this change, the validation should pass and you will be able to publish your email template without needing to bypass validation. Your emails will still render correctly with the actual cart data when they are sent.

The reason this started happening about 2 months ago is that HubSpot likely tightened their validation engine to catch more edge cases, but it ended up being overly strict for programmable modules where contact data is not available during the validation step. Adding the default filter is the standard workaround for this.

---

<div class="post-metadata">

**Author:** ![zoi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zoi/32/212157_2.png) [@zoi](https://community.hubspot.com/u/zoi)\
**Post date:** [December 23, 2025, 7:21am UTC](https://community.hubspot.com/t/fromjson-filter-stopped-working-in-programmable-email-modules-invalid-input-for-fromjson/144317/4 "2025-12-23T07:21:11Z")

</div>

HubSpot changed validation so fromjson fails if the contact property is empty during validation. To fix it, use a default JSON value so the validator has something valid to parse, for example:

`{% set cart_items = (contact.cart_items|default('[]'))|fromjson %}`

This stops the validation error and still works when real cart data is present.

---

<div class="post-metadata">

**Author:** ![fordnichols](https://avatars.discourse-cdn.com/v4/letter/f/839c29/32.png) [@fordnichols](https://community.hubspot.com/u/fordnichols)\
**Post date:** [December 23, 2025, 8:58pm UTC](https://community.hubspot.com/t/fromjson-filter-stopped-working-in-programmable-email-modules-invalid-input-for-fromjson/144317/5 "2025-12-23T20:58:02Z")

</div>

Thanks you all for the responses, however setting fallback defaults does not fix the error. It seems like it should but I tried every kind of syntax and no dice.

I finally managed to fix it through a bunch of trial and error by adding the following to my conditional:  
{% if cart\_items\_json and “[” in cart\_items\_json and “{” in cart\_items\_json %}

It’s a bit hacky but the only thing I could get to work. Checking for the those beginning chars in the json string must be enough to bypass the null or undefined value of {{ contact.cart\_items }} during validation.

So, for reference, my final code went from:

```lia-code-sample
{% set cart_items_json = contact.cart_items %}
{% set cart_items = cart_items_json|fromjson %}
{% for item in cart_items %}
 <!-- display cart item -->
{% endfor %}

```

to:

```lia-code-sample
{% set cart_items_json = contact.cart_items %}
{% if cart_items_json and "[" in cart_items_json and "{" in cart_items_json %}
 {% set cart_items = cart_items_json|fromjson %}
 {% if cart_items and cart_items|length > 0 %}
 {% for item in cart_items %}
 <!-- display cart item -->
 <!-- close conditionals -->

```
