# How to share code or flow json

**URL:** https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506
**Category:** FAQs
**Created:** [31 May 2018 14:17 UTC](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506 "2018-05-31T14:17:30Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [31 May 2018 14:17 UTC](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506/1 "2018-05-31T14:17:30Z")

</div>

To share code samples or flow json in this forum, you need to take care to format it properly so that it is displayed correctly.

The easiest way to do that is to click the 'Preformatted Text' button in the toolbar:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d56639561f3c9fa2f21f979311d7d4edcc5a9ef1.png)

Then paste in your code or flow json.

On standard US English keyboards, this is on the same key as the `~` character.

````auto
```
[{"id":"bbef23cc.4e7f18","type":"inject","x":100, "y": 50, "wires":[[]]}]
```

````

You can see the quotes remain untouched.

When sharing Flow JSON, add the text `flows` after the first set of back-ticks:

````auto
```flows
[{"id":"bbef23cc.4e7f18","type":"inject","x":100, "y": 50, "wires":[[]]}]
```

````

This will then get rendered as a flow:

```flows
[{"id":"bbef23cc.4e7f18","type":"inject","x":100, "y": 50, "wires":[[]]}]

```

For code from a Function node, first without the backticks:

msg.payload = "Hello There";  
return msg;

And again, with the backticks:

```auto
msg.payload = "Hello There";
return msg;

```

The added syntax highlighting also makes it much easier to read.

This should be used for _any_ code samples, such as flow JSON, JavaScript, html or XML samples.

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [31 May 2018 18:24 UTC](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506/3 "2018-05-31T18:24:54Z")

</div>

Also, larger flows can now be saved as a txt or json file and uploaded directly to the post.

Paul

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [16 March 2020 16:31 UTC](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506/4 "2020-03-16T16:31:13Z")

</div>



---

<div class="post-metadata">

### Author: ![euromem](https://avatars.discourse-cdn.com/v4/letter/e/d9b06d/32.png) [@euromem](https://discourse.nodered.org/u/euromem)
#### Post date: [25 May 2020 14:17 UTC](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506/5 "2020-05-25T14:17:07Z")

</div>

Complete beginner here, but I have ended up with tons of listings of "Home Assistant" as the server for Node-Red to connect to. Mauricio Bonani @mbonani wrote a JSON scrubber that I now use every time I import a flow in a post [https://bonani.tech/a-good-practice-when-sharing-node-red-flows-with-home-assistant-nodes/](https://bonani.tech/a-good-practice-when-sharing-node-red-flows-with-home-assistant-nodes/), with the actual scrubber at [https://zachowj.github.io/node-red-contrib-home-assistant-websocket/scrubber/](https://zachowj.github.io/node-red-contrib-home-assistant-websocket/scrubber/)

---

<div class="post-metadata">

### Author: ![mbonani](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mbonani/32/10631_2.png) [@mbonani](https://discourse.nodered.org/u/mbonani)
#### Post date: [25 May 2020 18:29 UTC](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506/6 "2020-05-25T18:29:17Z")

</div>

Thank you @euromem. Just a small correction, the scrubber was written by [Jason Zachow](https://github.com/zachowj), not by me.

---

<div class="post-metadata">

### Author: ![dclear](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dclear/32/9107_2.png) [@dclear](https://discourse.nodered.org/u/dclear)
#### Post date: [23 June 2020 18:17 UTC](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506/7 "2020-06-23T18:17:33Z")

</div>

Just to note the advice of pasting in your code then selecting then clicking preformatted text doesn't seem to work reliably - [apparently](https://discourse.nodered.org/t/trying-to-work-out-why-not-getting-updates-for-a-particular-output-from-a-script/28810/4) it's better to click the button then paste your text into the newly created 'space'.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [23 June 2020 18:21 UTC](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506/8 "2020-06-23T18:21:44Z")

</div>

@dclear thanks - have updated the guidance to match

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [6 July 2020 18:06 UTC](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506/10 "2020-07-06T18:06:20Z")

</div>


