How to Escape Backslash Immediately Before Expressions?

Describe the problem/error/question

It seems that a backslash immediately preceeding an {{ expression }} prevents the expression from being evaluated during execution. However it appears as if it is/will be evaluated during preview.

This first screenshot shows that {{ $json.key1 }}{{ $json.key2 }} will evaluate to “val1\val2” which is expected behavior. However the second screenshot shows execution evaluating it to something different, “val1{{ $json.key2 }}”

Using a double-backslash doesn’t change this behavior. Is there a different escape character available so that the backslash can immediately preceed an expression to be evaluated during execution?

Thanks!


What is the error message (if any)?

None

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

n8n Version 1.60.1, postgres, AWS EKS

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @jzrts ,

If you add a space after the backlash the expression reads well in both preview and output. Same if you use a forward slash (no space needed).
What suits you will depend on what your intended usecase is - would adding a space solve this for you or does your usage require another solution? :sunflower:

1 Like

Is there any resolution to this. I am trying to pass a network path as part of an expression, and even though adding the space does resolve correctly it also makes the path invalid.

Figured it out

Do this {{ ‘\\’ + $json.server_name }}

instead of this \\{{ $json.server_name }}

Thanks.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.