# Function new line

**URL:** <https://discourse.nodered.org/t/function-new-line/19927>\
**Category:** Dashboard\
**Created:** [5 January 2020 12:23 UTC](https://discourse.nodered.org/t/function-new-line/19927 "2020-01-05T12:23:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![pvanklink](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@pvanklink](https://discourse.nodered.org/u/pvanklink)\
**Post date:** [5 January 2020 12:23 UTC](https://discourse.nodered.org/t/function-new-line/19927/1 "2020-01-05T12:23:50Z")

</div>

Hi,

I made a function that creates the content for a dashboard text node.  
This function works great!  
But i like to have some newlines between some of the content parts when showing the info on the dasboard, is that possible?

I tried to '/n' at some places in the payload string but that did not work

msg.payload = 'Server: ' + msg.server + ' is NIET beschikbaar'

if(msg.run)  
{msg.payload = msg.payload + ' en krijgt OScommand: ' + msg.oscmd + ', iD: ' + msg.devid + ', Counter:' + msg.teller + '/' + msg.repetitions + ', Errors:' + msg.tellererror;}  
else  
{msg.payload = msg.payload + ', iD: ' + msg.devid + ', Counter:' + msg.teller + '/' + msg.repetitions + ', Errors:' + msg.tellererror;}

if(msg.notifyok)  
{msg.payload = msg.payload + '. Notificatie wordt verzonden naar: ' + msg.device;}

else if (msg.notifynok)  
{msg.payload = msg.payload + '. Notificatie wordt verzonden naar: ' + msg.device;}

else  
{}

return msg;

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [5 January 2020 12:29 UTC](https://discourse.nodered.org/t/function-new-line/19927/2 "2020-01-05T12:29:41Z")

</div>

Wrap each "line" (paragraph really) with `<p>....</p>` or `<div>...</div>`

Or, if you really only need a line break, add `<br>` at the end of the line.

Your template output needs to be HMTL.

---

<div class="post-metadata">

**Author:** ![pvanklink](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@pvanklink](https://discourse.nodered.org/u/pvanklink)\
**Post date:** [5 January 2020 14:21 UTC](https://discourse.nodered.org/t/function-new-line/19927/3 "2020-01-05T14:21:53Z")

</div>

Thanks!  
I will try it!

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [5 January 2020 15:08 UTC](https://discourse.nodered.org/t/function-new-line/19927/4 "2020-01-05T15:08:43Z")

</div>

Also newline is \n not /n

---

<div class="post-metadata">

**Author:** ![pvanklink](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@pvanklink](https://discourse.nodered.org/u/pvanklink)\
**Post date:** [5 January 2020 15:58 UTC](https://discourse.nodered.org/t/function-new-line/19927/5 "2020-01-05T15:58:54Z")

</div>

It Works with the

 option, thanks to all!  
Will also try \<\n\>

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [5 January 2020 17:02 UTC](https://discourse.nodered.org/t/function-new-line/19927/6 "2020-01-05T17:02:20Z")

</div>

it works with \<br\>. use \ to esacpe \< so it renders on screen, so \\<br\>  
but do not use \<\n\> just \n

---

<div class="post-metadata">

**Author:** ![pvanklink](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@pvanklink](https://discourse.nodered.org/u/pvanklink)\
**Post date:** [5 January 2020 17:44 UTC](https://discourse.nodered.org/t/function-new-line/19927/7 "2020-01-05T17:44:40Z")

</div>

Thanks! works perfect!

---

<div class="post-metadata">

**Author:** ![albfan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/albfan/32/14662_2.png) [@albfan](https://discourse.nodered.org/u/albfan)\
**Post date:** [2 May 2022 09:58 UTC](https://discourse.nodered.org/t/function-new-line/19927/8 "2022-05-02T09:58:21Z")

</div>

if payload contains newlines like "hello\nworld\n\tnodered!"

```
<pre>{{msg.payload}}</pre>

```

should show it verbatim on text UI widget

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [2 May 2022 10:06 UTC](https://discourse.nodered.org/t/function-new-line/19927/9 "2022-05-02T10:06:33Z")

</div>


