Shopify removes   from the product description

Topic summary

Issue: Shopify’s product description editor automatically removes non-breaking space entities ( ) when users switch between code and preview modes, even though these are intentionally placed (e.g., between numbers and units like “10 bar”).

Explanations provided:

  • This is intentional behavior, not a bug
  • Shopify’s Liquid templating engine escapes special characters by design
  • Theme code may include escape string handlers that strip these entities

Suggested workarounds:

  • Use CSS properties like white-space: nowrap; for layout control
  • Apply JSON filters with string replacement in Liquid code (example provided using | json | replace filters)

Status: The original poster reported the issue resolved temporarily on its own, though another user later requested clarification on implementing the solutions, indicating the problem persists for some users.

Summarized with AI on October 31. AI used: claude-sonnet-4-5-20250929.

I’m editing the product description in the html code editor mode, so I’m marking up where I use non-breaking space between a number and a unit of measurement. For example,

10 bar

But today I noticed that Shopify just deletes non-breaking space after switching to preview mode and back to code editing. However, Shopify itself places the   but not where I need them.

How does it work? Is this a Shopify error?

1 Like

Hi @Anastasiia_D ! Most likely in your theme’s code there is an escape string handler for this block, which removes all special characters. More details here: https://shopify.github.io/liquid/filters/escape/

you could consider using CSS properties like white-space: nowrap; or adjusting the layout and styling to accommodate the desired spacing. Shopify’s code editor has a feature that automatically removes non-breaking spaces ( ) when switching between preview mode and code editing mode. This behavior is intentional and not an error.

2 Likes

Not an error, Shopify with Liquid will escape characters (no left and right special chars). It’s a normal behaviour.

1 Like

I didn’t even exited the product card editor. I just used the “code mode” button for the description, wroted the text and used “view mode” and then “code mode” again.

But thank you for your reply. This problem was temporary for me, but now everything is ok, I didn’t notice it anymore.

Thank you. Yes, I already use this method, it works well.

Hi :victory_hand:

Just use a JSON filter and then replace the string with the correct view. Example:

{%- liquid
  echo "10 bar" | json | replace: '\u0026nbsp;', ' ' | replace: '\u003c', '<' | replace: '\u003e', '>'
-%}

Hi @Anastasiaa_D,

I have the same issue - Shopify removes non-breaking spaces ( ) - and I have read all this thread but I was not able to understand what am I supposed to do :slightly_smiling_face:

Could you let me know if you found a solution to add non-breaking spaces in product descriptions and other texts?

Thanks for your attention.

Audrey