Skip to content

Visual output does not correctly render formatted Markdown in the Set node / Expression Editor result panel #21656

@matheuspimentaa

Description

@matheuspimentaa

Bug Description

When using the expression editor ({{ }}) inside a Set node to build Markdown text with multiple line breaks and lists (e.g., using map().join('\n')), the result panel on the right (“Result”) does not display the formatted text properly.

The content is generated correctly internally, but the visual preview is misaligned, with inconsistent line breaks and indentation — as if the Markdown was partially converted to plain text.

In the attached image, you can see that the right-hand side output loses its original structure (lines overlap, indentation is off, and there are inconsistencies between text blocks and lists).

To Reproduce

  1. Create a new workflow in n8n.

  2. Add a Set node.

  3. Create a field, for example named contexto_empresa.

  4. Enable “Use Expression” and insert the following code:

    You work for {{ $json.company_name }}, and your research should use the following company context:
    
    **Niche:**
    {{ $json.niche }}
    
    **Ideal Client Profile:**
    {{ $json.icp }}
    
    **Offer:**
    {{ $json.offer }}
    
    **Company Description:**
    {{ $json.description_business }}
    
    **Titles of articles published in the last 12 months:**
    {{ $json.articles_last_12_months.map(article => `- ${article.title}`).join('\n') }}
  5. Provide a simple JSON input, like:

    {
      "company_name": "Digital OTT",
      "niche": "Real estate market. Agencies, developers, and construction companies",
      "icp": "- Real estate agents\n- Real estate company owners\n- Developers",
      "offer": "Digital marketing strategy to scale qualified leads and sell more properties",
      "description_business": "We are a digital marketing agency specialized in the real estate market.",
      "articles_last_12_months": [
        {"title": "Local SEO for Real Estate Agencies and Developers"},
        {"title": "Real Estate Lead Generation: 7 Proven Strategies"}
      ]
    }
  6. Execute the workflow.

  7. Observe the “Result” panel on the right: the rendered text does not preserve line breaks and lists correctly.

Expected behavior

The Expression Editor result panel should render the output exactly as it will appear in the final node output — preserving line breaks, lists, and indentation in a faithful Markdown or plain text representation.

Expected:

  • Line breaks (\n) should be respected and shown as new lines

  • Lists using - should be correctly displayed

  • Proper separation between text sections

Debug Info

  • Environment: n8n self-hosted

  • Version: 1.117.3

  • Operating System: Ubuntu 22.04 LTS

  • Affected Node: SetExpression EditorResult Preview

  • Actual Result: Text rendered with incorrect spacing and line breaks

  • Expected Result: Properly formatted text with preserved line breaks and Markdown structure

Operating System

Ubuntu Linux 22.04 LTS

n8n Version

1.117.3

Node.js Version

v20.19.5

Database

PostgreSQL

Execution mode

main (default)

Hosting

self hosted

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions