# TIDY.JS to the function node

**URL:** <https://community.n8n.io/t/tidy-js-to-the-function-node/7365>\
**Category:** Feature Requests\
**Created:** [August 19, 2021, 8:21am UTC](https://community.n8n.io/t/tidy-js-to-the-function-node/7365 "2021-08-19T08:21:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ed\_P](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ed_p/32/98978_2.png) [@Ed\_P](https://community.n8n.io/u/Ed_P)\
**Post date:** [August 19, 2021, 8:21am UTC](https://community.n8n.io/t/tidy-js-to-the-function-node/7365/1 "2021-08-19T08:21:42Z")

</div>

Hello.  
I’ve started to use n8n just recently and I’m absolutely amazed by many unique ideas compared to other automation tools.

Function node in particular is great, however it may be a bit tedious to perform **data wrangling** in JS.

From my opinion, JS is just simply not the best tool for that. Speaking of “best tool” for data wrangling, there are several other options like SAS and R. As a data analyst by trade, I use them all the time and recently came across one interesting JS project that tries to unite these “worlds”:  
[tidy.js (pbeshai.github.io)](https://pbeshai.github.io/tidy/)

I wanted to ask whether it’s possible to use tidy.js in n8n workflows? I’m thinking primarily about writing custom code in function node, but maybe some custom nodes can also be created. My experience in docker \ JS is very modest, so I was able to follow instructions and install n8n via docker-compose. But I have no idea how one can connect some “external” JS framework to n8n.

Hope my question makes sense and some steps can be done even without any official support of tidy.js

Regards,  
Eduard

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [August 19, 2021, 9:58am UTC](https://community.n8n.io/t/tidy-js-to-the-function-node/7365/2 "2021-08-19T09:58:08Z")

</div>

I have not tried it myself but you can import modules to use in the functions, There is a bit of text about how to do it below that might be useful to you.

> [@Socks5 support in http request node?](http://community.n8n.io/t/socks5-support-in-http-request-node/6301/4):
>
> Yes, but again, you have to: Add the library socks5-http-client to /n8n/packages/nodes-base/package.json Reference the [custom](https://github.com/n8n-io/n8n/tree/master/docker/images/n8n-custom) image in the docker-compose file. Set the env variable NODE\_FUNCTION\_ALLOW\_EXTERNAL=socks5-http-client Require and use the library within the function node.

---

<div class="post-metadata">

**Author:** ![Ed\_P](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ed_p/32/98978_2.png) [@Ed\_P](https://community.n8n.io/u/Ed_P)\
**Post date:** [August 19, 2021, 10:55am UTC](https://community.n8n.io/t/tidy-js-to-the-function-node/7365/3 "2021-08-19T10:55:51Z")

</div>

Ah, thanks a lot.  
I didn’t realise those are called external functions.  
Probably this will be a bit trickier to install on docker-compose, but at least it’s clear where to look at.

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [August 19, 2021, 10:57am UTC](https://community.n8n.io/t/tidy-js-to-the-function-node/7365/4 "2021-08-19T10:57:40Z")

</div>

I think that is the case or it is at least how I read it anyway so it could be handy or it could be useless.

---

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [August 19, 2021, 2:00pm UTC](https://community.n8n.io/t/tidy-js-to-the-function-node/7365/5 "2021-08-19T14:00:39Z")

</div>

I checked the library and it seems similar to lodash. We use lodash internally, meaning you can use it within a function by just setting the `NODE_FUNCTION_ALLOW_EXTERNAL=lodash`. Unlike Tidy.js that if you wanted to use you would need to create a custom image that includes that library as a dependency.

In the function node you use it as shown below:

```auto
const lodash = require('lodash')

//do whatever with it

return [
  {
    json: {
    }
  }
]

```

So that you know, we are currently working on a data transformation node that will help with arrays.

---

<div class="post-metadata">

**Author:** ![Ed\_P](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ed_p/32/98978_2.png) [@Ed\_P](https://community.n8n.io/u/Ed_P)\
**Post date:** [August 19, 2021, 3:09pm UTC](https://community.n8n.io/t/tidy-js-to-the-function-node/7365/6 "2021-08-19T15:09:52Z")

</div>

Thanks a lot! I’ll try this.

May I ask how does this part exactly work?  
`const lodash = require('lodash')`

Do I understand correctly that it’s fine to **require()** external functions every time the node runs?

From other languages (like R, Pythin, C++) I would expect that externals are called once per program, but not every time the cycle runs (I can imagine function node as a cycle if it runs periodically). Or it doesn’t really matter in case of JS?

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [August 19, 2021, 3:20pm UTC](https://community.n8n.io/t/tidy-js-to-the-function-node/7365/7 "2021-08-19T15:20:24Z")

</div>

Your function node will run when it is called in the workflow but make sure you use the right one as there are 2 you can learn about them both here: [Key concepts | Docs](https://docs.n8n.io/getting-started/key-concepts.html#function)

The `const lodash = require('lodash')` is a bit like if you were to run `import pandas as pd` in Python so you would be setting the lodash variable to the library so you can use `lodash.whatever` which in the Python example would be `pd.whatever`. Hopefully this helps, You can find the lodash documentation to see what is available here: [Lodash Documentation](https://lodash.com/docs/4.17.15)
