# Convert Node Red to C Code

**URL:** https://discourse.nodered.org/t/convert-node-red-to-c-code/35070
**Category:** General
**Created:** [30 October 2020 11:15 UTC](https://discourse.nodered.org/t/convert-node-red-to-c-code/35070 "2020-10-30T11:15:32Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![iak34](https://avatars.discourse-cdn.com/v4/letter/i/b3f665/32.png) [@iak34](https://discourse.nodered.org/u/iak34)
#### Post date: [30 October 2020 11:15 UTC](https://discourse.nodered.org/t/convert-node-red-to-c-code/35070/1 "2020-10-30T11:15:32Z")

</div>

Hello, is there a possibility to create C code from Node Red? My Idea is to Create C Code for Microcontrollers and other devices from specific nodes. Maybe it is possible to use the JSON File?

---

<div class="post-metadata">

### Author: ![Kib](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kib/32/27493_2.png) [@Kib](https://discourse.nodered.org/u/Kib)
#### Post date: [30 October 2020 11:18 UTC](https://discourse.nodered.org/t/convert-node-red-to-c-code/35070/2 "2020-10-30T11:18:39Z")

</div>

I have been in such an endaeveor myself. I tried searching to convert .json nodes and wires to .tick scripts. The only conclusion i found was to build a transpiler(not really)/interpretor myself.

Please keep this thread posted of you do find any. 🙂

But how do you wish for this process happen? like, what nodes do you have in your nodered that you need to convert to a compilable c code.  
The first thing i tried in my case was to use nodes and edit a single .tick file, adding functionality(lines to the same file), with each connection.  
but the problem will still be to make it compilable and runnable.

- order of execution cannot be maintained.
- and syntax rules cannot be enforced.

or atlast it is too cumbersome to do the said process.

one thing you could do is build c structs from json objects like this, create a node module which would analyse the struct to create a linked data structure, then write rules explicitly on how to handle a node type, to produce a valid c file. (but nothing can be guaranteed)

---

<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: [30 October 2020 17:35 UTC](https://discourse.nodered.org/t/convert-node-red-to-c-code/35070/3 "2020-10-30T17:35:16Z")

</div>

> [@Kib](#):
>
> interpretor

These certainly exist for certain microcontrollers. Both Python & JavaScript is available.

Doesn't answer the original question really though.

There are some tools aiming to cross-compile JavaScript to C

- [ts2c](https://github.com/andrei-markeev/ts2c)
- [NectarJS](https://github.com/NectarJS/nectarjs/issues/46)

Doubt they will be of much use but you never know.

There are also things like [Haxe](https://haxe.org/) but that is a separate language capable of outputting several different language code types including JavaScript and C

Also see [Convert javascript code to c code - Stack Overflow](https://stackoverflow.com/a/31307856/1309986)

---

<div class="post-metadata">

### Author: ![Kib](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kib/32/27493_2.png) [@Kib](https://discourse.nodered.org/u/Kib)
#### Post date: [1 November 2020 12:21 UTC](https://discourse.nodered.org/t/convert-node-red-to-c-code/35070/4 "2020-11-01T12:21:56Z")

</div>

> [@iak34](#):
>
> JSON File?

> [@iak34](#):
>
> C code from Node Red

hence this was replied in the first part .. @TotallyInformation

> [@Kib](#):
>
> But how do you wish for this process happen? like, what nodes do you have in your nodered that you need to convert to a compilable c code.

> [@TotallyInformation](#):
>
> Doesn't answer the original question really though.

I think it does, doesnt it?

---

<div class="post-metadata">

### Author: ![iak34](https://avatars.discourse-cdn.com/v4/letter/i/b3f665/32.png) [@iak34](https://discourse.nodered.org/u/iak34)
#### Post date: [3 November 2020 08:48 UTC](https://discourse.nodered.org/t/convert-node-red-to-c-code/35070/5 "2020-11-03T08:48:37Z")

</div>

Thank you for your support. I dont know where i can get the Javascript code to cross compile it to C? I can only downlaod the JSON file?

---

<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 January 2021 08:48 UTC](https://discourse.nodered.org/t/convert-node-red-to-c-code/35070/6 "2021-01-02T08:48:44Z")

</div>

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