# Copy to clipboard

**URL:** <https://discourse.nodered.org/t/copy-to-clipboard/34489>\
**Category:** General\
**Created:** [19 October 2020 09:30 UTC](https://discourse.nodered.org/t/copy-to-clipboard/34489 "2020-10-19T09:30:08Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![MA.ING](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MA.ING](https://discourse.nodered.org/u/MA.ING)\
**Post date:** [19 October 2020 09:30 UTC](https://discourse.nodered.org/t/copy-to-clipboard/34489/1 "2020-10-19T09:30:08Z")

</div>

Hi, I am trying to create a button that copies a text to the clipboard from the dashboard but I can't do it in any way or with any node, could someone who has done something similar help me? Thank you

---

<div class="post-metadata">

**Author:** ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)\
**Post date:** [19 October 2020 10:22 UTC](https://discourse.nodered.org/t/copy-to-clipboard/34489/2 "2020-10-19T10:22:09Z")

</div>

You could probably use a bash script to copy to clipboard if you are using linux/mac , and then execute that bash script via node-red exec node...

---

<div class="post-metadata">

**Author:** ![MA.ING](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MA.ING](https://discourse.nodered.org/u/MA.ING)\
**Post date:** [19 October 2020 10:42 UTC](https://discourse.nodered.org/t/copy-to-clipboard/34489/3 "2020-10-19T10:42:39Z")

</div>

im using node-red in windows

---

<div class="post-metadata">

**Author:** ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)\
**Post date:** [19 October 2020 10:57 UTC](https://discourse.nodered.org/t/copy-to-clipboard/34489/4 "2020-10-19T10:57:00Z")

</div>

Well i think this [answer](https://superuser.com/a/231032/1157605) will help you , just make sure to format the command string properly with the value you want to copy, and then execute the command via exec node 😃

---

<div class="post-metadata">

**Author:** ![MA.ING](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MA.ING](https://discourse.nodered.org/u/MA.ING)\
**Post date:** [19 October 2020 11:16 UTC](https://discourse.nodered.org/t/copy-to-clipboard/34489/5 "2020-10-19T11:16:10Z")

</div>

but this only works with one permanent text no?, i want to take variable text from dashboard and copy it to my clipboard by clicking a button of dashboard.

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)\
**Post date:** [19 October 2020 11:50 UTC](https://discourse.nodered.org/t/copy-to-clipboard/34489/6 "2020-10-19T11:50:49Z")

</div>

> [@MA.ING](#):
>
> Hi, I am trying to create a button that copies a text to the clipboard from the dashboard but I can't do it in any way or with any node, could someone who has done something similar help me?

You can do this using the dashboard template node.

1. Copy paste [W3Schools Tryit Editor](https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_copy_clipboard) in the template node.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/5/05628341862ebc72377092ee3039636b45189b38.png)
2. Then you can further modify the html/javascript of the template node to your needs.
3. I would send the dynamic text to copy to the clipboard as msg.payload to the template node.
4. In template node code you can refer to the payload by `{{msg.payload}}`

---

<div class="post-metadata">

**Author:** ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)\
**Post date:** [19 October 2020 12:50 UTC](https://discourse.nodered.org/t/copy-to-clipboard/34489/7 "2020-10-19T12:50:27Z")

</div>

This is even better solution than mine 😁

---

<div class="post-metadata">

**Author:** ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)\
**Post date:** [19 October 2020 12:52 UTC](https://discourse.nodered.org/t/copy-to-clipboard/34489/8 "2020-10-19T12:52:28Z")

</div>

If you implement msg.payload instead of the abc, it would work. But janvda method is 100% better than mine, and it will copy on any device, my script will only copy on server side.

---

<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:** [19 October 2020 13:14 UTC](https://discourse.nodered.org/t/copy-to-clipboard/34489/9 "2020-10-19T13:14:29Z")

</div>

> [@MA.ING](#):
>
> copies a text to the clipboard from the dashboard

This is down to your browser and OS, not Node-RED.

Allowing the browser to control access to the clipboard is fraught with security issues which is why it isn't necessarily easy.

Please share what browser you want to target.

---

<div class="post-metadata">

**Author:** ![MA.ING](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MA.ING](https://discourse.nodered.org/u/MA.ING)\
**Post date:** [19 October 2020 14:22 UTC](https://discourse.nodered.org/t/copy-to-clipboard/34489/10 "2020-10-19T14:22:02Z")

</div>

Thank you, it works as I wanted.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 November 2020 14:22 UTC](https://discourse.nodered.org/t/copy-to-clipboard/34489/11 "2020-11-02T14:22:09Z")

</div>

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