TIDY.JS to the function node

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)

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


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.

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.

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.

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:

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.

1 Like

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?

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

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

1 Like