// guides · n8n error index

n8n Markdown node not working: tables, line breaks and AI output in emails, 38 runs

Why the n8n Markdown node leaves tables as pipes, merges lines, writes no output or fails with text.replace is not a function, and what HTML to Markdown drops. 38 real runs on n8n 2.43.7.

Updated 2026-10-24 · about 10 minutes

Still stuck after these steps? Paste your exact n8n error and we'll reproduce it and email you the fix, free →

Steps

  1. Point the field at the text with an expression

    The Markdown field must be in Expression mode. In Fixed mode, {{ $json.text }} came out literally as <p>{{ $json.text }}</p> with a green run. Check the field name in the input panel too: AI Agent nodes usually put their answer in output. When we pointed Markdown to HTML at a field that didn't exist, the run was green but no destination key was written at all, so the next node got the item unchanged. HTML to Markdown is the opposite: a missing field failed with Cannot convert undefined or null to object.

  2. Turn on Tables and Simple Line Breaks for AI output

    With default options a GitHub-style table stayed as raw pipes inside one paragraph, and two lines separated by a single newline merged into one. That is why AI reports look broken in emails. Options, Tables gave a real <table>, and Simple Line Breaks turned each newline into <br />. Strikethrough, Tasklists and Simplified Auto Link are also off by default, so ~~old~~, - [ ] task and bare URLs stay as plain text until you enable them.

  3. Fix literal \n from the AI

    If the text shows \n as two characters (the model returned escaped or double-encoded JSON), the converter sees one long line. Our test ended with everything inside one <h1>, visible \n included. Replace them first: {{ $json.output.replaceAll('\\n', '\n') }}, or parse the JSON properly before the Markdown node.

  4. Send a string, not an object or number

    An object or a number in the field failed with text.replace is not a function. Point at the string field, or wrap it: {{ String($json.total) }} or {{ JSON.stringify($json.data) }}. An empty string and null passed through without an error, so empty AI answers send empty emails.

  5. Protect snake_case, hashtags and sublists

    By default file_name_v2 became file<em>name</em>v2 and 2*3*4 became 2<em>3</em>4; turn on Literal Mid Word Underscores and Literal Mid Word Asterisks. A line starting with #hashtag became a heading until Require Space Before Heading Text was on. A bullet indented 2 spaces under a numbered item broke the list in two; indent 4 spaces or enable Disable Forced 4 Spaces Indented Sublists.

  6. Choose the output key and document type

    The result goes to Destination Key, data by default. A dotted key such as email.body created a nested object, and text overwrote your Markdown. Complete HTML Document wraps it in a full <!DOCTYPE HTML> page, which you only need if the email node or file wants one. Headings get automatic ids (helloworld, helloworld-1); No Header ID removes them.

  7. Sanitise before you email or render it

    Raw HTML in the Markdown, including <script>, passed straight into the output. If the text comes from an AI model, a form or an email, strip tags first (for example with a Code node) before you put it into a page. From general experience rather than our runs: many email clients strip <input> checkboxes, so Tasklists may not show in emails.

  8. HTML to Markdown: images, escapes and blank lines

    HTML to Markdown dropped <style> and <script>, turned tables into pipe tables and <br> into a two-space line break. A data: image was dropped silently until Keep Data Images was on. Literal *, _ and 1. in text were backslash-escaped (15\_total), which doubles up if you then escape for Telegram MarkdownV2 or Slack. Gmail-style <div><br></div> left stray blank lines; Max Consecutive New Lines trims them. Nested tables were flattened and the outer table lost, and the Ignore option didn't remove the table in our test, so clean the HTML first if you need that.

What we ran

On 24 October 2026 we ran 38 executions on self-hosted n8n 2.43.7 with n8n execute: Manual Trigger, a Code node with test Markdown or HTML, the Markdown node (v1) with different options, and a Code node that recorded the output. 25 runs were Markdown to HTML and 13 were HTML to Markdown; 35 succeeded and 3 failed.

SetupResult
AI-style report, default optionsHeadings, bold and code fences convert; a GitHub table stays as raw pipes inside one <p>
Same, Tables option onReal <table><thead><tbody>
Two lines with a single newline, defaultMerged into one paragraph, no <br>
Simple Line Breaks onSingle newline becomes <br />
~~old~~ and - [ ] task, defaultLeft as literal text
Strikethrough and Tasklists on<del> and disabled checkbox <input> elements
Bare https URL, defaultNot a link; Simplified Auto Link makes it an <a>
Markdown field in Fixed mode with {{ $json.text }}Output is literally <p>{{ $json.text }}</p>, green run
Field pointing at $json.output, text is in $json.textGreen run, no destination key written at all
Object or number in the fieldError: text.replace is not a function
Empty string; null""; null, no error
Destination Key email.bodyNested {"email":{"body":...}}
Destination Key textOverwrites the source Markdown
Complete HTML Document onFull <!DOCTYPE HTML><html><head> document
Two headings Hello WorldIds helloworld and helloworld-1; No Header ID removes them
#hashtag at line startBecomes a heading unless Require Space Before Heading Text
file_name_v2 and 2*3*4, defaultfile<em>name</em>v2, 2<em>3</em>4
Literal Mid Word Underscores and Asterisks onLeft as written
Raw <b> and <script> in the MarkdownPassed straight through, nothing sanitised
Open Links In New Windowtarget="_blank" rel="noopener noreferrer"
Emoji option, :smile: :rocket:Unicode emoji
Nested list indented 2 spaces under 1.List broken into <ol></ol><ul></ul><ol>
AI text with literal \n charactersEverything inside one <h1 id="titlennboldnitem"> with visible \n
2 input items2 outputs, one conversion per item
HTML to Markdown, default<style>/<script> dropped, tables become pipe tables, <ul> becomes * bullets
HTML with a data: image, defaultImage dropped silently; Keep Data Images keeps it
Text with *, _ and 1.Backslash-escaped: \*stars\*, 15\_total, 1\.
HTML to Markdown, field missingError: Cannot convert undefined or null to object
Gmail-style <div><br></div> and &nbsp;Stray blank lines; Max Consecutive New Lines trims them
Bullet Marker -, Strong Delimiter __- one, __Anna__
<pre><code class="language-js">A ```js fence
Nested tableFlattened to one table, outer table lost
Object in the HTML fieldNo error: each value converted, {"a":1} became {"a":"1"}

Good to know

What we didn't test

FAQ

Why does my Markdown table show as pipes in n8n?

The Markdown node leaves tables off by default. Open Options and turn on Tables, and the table becomes real HTML.

Why are my line breaks lost after the n8n Markdown node?

Standard Markdown joins lines separated by a single newline into one paragraph. Turn on Simple Line Breaks to get a br for each newline.

Why does the n8n Markdown node output nothing?

If the Markdown field points at a field that doesn't exist, or is in Fixed mode, the run stays green and no output key is written or the braces come out as text. Use Expression mode and the right field, often output for AI Agent nodes.

What does "text.replace is not a function" mean in the n8n Markdown node?

The field holds an object or a number, not a string. Point it at the text field or wrap it in String() or JSON.stringify().

How do I send AI agent output as a nice HTML email in n8n?

Use the Markdown node, Markdown to HTML, on the agent output with Tables and Simple Line Breaks on, replace any literal \n first, then put the data field into the email node's HTML body.

Why does HTML to Markdown add backslashes in n8n?

It escapes characters that would otherwise be read as Markdown, such as * _ and 1. at the start of a line. Remove them or skip conversion if your target, like Telegram MarkdownV2, does its own escaping.

Related guides

New guides

Still stuck on your n8n error?

Paste the exact error and say what the workflow should do. We reproduce it on a real n8n install and email you the fix or a working workflow, usually within 24h. Free while we're in beta.

We'll only email you about your error and TaskToAgent.