Python or JavaScript code step? Choosing a language for custom logic
By Maria Soria, Manager of Customer Success


When customers move to Neblex from another automation tool, one of the first things they ask me about is their existing scripts. My first answer is a question: what does each script do? Many of them exist only because the old tool had no native step for the job at the time, or because code was the simplest approach, such as replacing a long chain of native steps.
Here is how I help customers decide: when a built-in step does the job, which language to use when it doesn't, and what each one can and can't reach. I tested all three languages in a flow when writing this. We also migrated 31 scripts (the kinds customers bring us) into Neblex, and what happened to them runs through each section below.
Do you need a code step at all?
The scripts that turn into built-in steps tend to do the same few jobs: formatting a phone number, flattening a list, totaling orders per customer, checking a business rule. They were written as code because that was the only option, or the one that made the most sense then.
So before we port anything, I ask two questions about each script: what does it do to a record, in one sentence, and is there a built-in step that says the same thing? If you're coming from a pro-code automation tool, these are jobs I commonly see written as code that don't need code in Neblex:
| The job that usually ends in a code step | Built-in step in Neblex |
|---|---|
| Format phone numbers to E.164, convert country names to ISO codes | Normalize |
| Find fuzzy duplicates, like Jonathon and Jonathan Smith | Remove duplicates |
| Validate JSON against a schema and list every error | Validate Records |
| Check an IBAN or a barcode (GTIN) check digit | Edit text (built-in validators) |
| Calculate the median, a percentile or the standard deviation per group | Group & summarize |
| Validate XML against an XSD | XML |
| Parse an X12 850 purchase order and send a 997 acknowledgment | Read EDI, Acknowledge EDI |
| Generate a PDF invoice from a template | Create PDF |
In our test, we moved 31 scripts into Neblex, and 17 of them didn't need to stay code: a built-in step did the same job, with the same output on every record. Four of those relied on npm packages or Node modules, such as lodash and Node's crypto, so replacing them also removed a dependency to install and maintain.
A built-in step shows its settings in the editor, so anyone can see what it does without reading code.
Use a Code step for rules specific to your business that no step expresses: a validation that depends on several fields at once, a calculation your finance team defined, or exact money math. Keep the script to that rule, and let built-in steps do the work around it.
How the Code step works in each language
The Code step runs a script over the records a step receives. It offers three languages and two modes:
| Rhai | JavaScript | Python | |
|---|---|---|---|
| Each record | The script works on item and returns it | transform(item) returns the new record | transform(item) returns the new record |
| All records | fn step(batch), plus an optional fn finish(parts) | transform(items) returns the new list | transform(items) returns the new list |
| Drop a record | Leave it out of what step returns (All records mode) | Return null | Return None |
| Reuse across flows | Imported Transform Modules and the snippet library | Copy the script | Copy the script |
Rhai is the default language. In Each record mode, a Rhai script always outputs one record per input record.
JavaScript code step: pros and cons
JavaScript is the language most people I work with have used, and it is a natural fit for JSON records. Object spread, map, filter, and regular expressions make reshaping a record short and readable. Code from Node-based automation tools usually needs only its wrapper changed, as pricing rules, lead scoring, and an order-splitting script did for us.
function transform(item) {
if (item.qty === 0) return null; // drop empty order lines
const name = item.name.trim().split(/\s+/)
.map(w => w[0].toUpperCase() + w.slice(1).toLowerCase()).join(' ');
return { ...item, name, email: item.email.trim().toLowerCase() };
}The trade-offs:
- No packages. There is no
requireor npm, so you either write a helper into the script or replace it. - Numbers are binary floating point, so
0.1 + 0.2isn't exactly0.3. For money, work in integer cents or do the math in a Python step.
Python code step: pros and cons
Python reads almost like plain English, which helps when the person maintaining the code isn't the person who wrote it. Its standard library is the main reason to pick it: decimal for exact money math, statistics for averages and medians, re for text checks, hashlib for match keys, and datetime for arithmetic on dates from your data. A messy CSV export, invoice totals, an address parser, and dates in nine formats all ran unchanged in our test.
import re, decimal
def transform(item):
total = decimal.Decimal(str(item["price"])) * item["qty"]
item["total"] = str(total.quantize(decimal.Decimal("0.01")))
item["email_valid"] = bool(re.fullmatch(r"[^@\s]+@[^@\s]+\.[a-z]{2,}", item["email"]))
return itemThe trade-offs:
- Standard library only, and without its modules for files, the network and processes. Libraries you would normally install with pip, such as pandas or requests, aren't available.
- No files, network, or subprocesses, so scripts that read a local file or call an API need those parts moved into connector steps.
Rhai code step: pros and cons
Rhai is a scripting language made for embedding in other software, and in Neblex it is the only one of the three with built-in reuse. You can save functions as a Transform Module and import it into any flow in your workspace. Each run loads the module's current version, so a fix reaches every flow that uses it. Our library of Rhai functions for dates, amounts, and match keys works this way.
fn step(batch) {
let total = 0.0;
for r in batch { total += r.total; }
#{ n: batch.len(), total: total }
}
fn finish(parts) {
let n = 0; let total = 0.0;
for p in parts { n += p.n; total += p.total; }
[#{ records: n, grand_total: total }]
}Its All records mode also works differently. You write step(batch) for one batch of records and finish(parts) to combine the results, so a total or summary over many records is worked out batch by batch and combined at the end.
The trade-offs:
- Fewer people know Rhai, and there are fewer examples online than for JavaScript or Python.
- Its built-in functions are basic, so you write helpers yourself or import a module.
- The syntax looks like JavaScript and Rust but isn't either, which trips people up at first.
Python or JavaScript code step: which language for which job
| Job | Best fit | Why |
|---|---|---|
| Reshape or clean JSON records | JavaScript | Short, familiar syntax for objects and arrays |
| Code moved from a Node-based tool | JavaScript | Usually only the wrapper changes |
| Money math that must be exact | Python | decimal avoids floating-point rounding |
| Averages, medians, ranking | Python | statistics in the standard library |
| Code moved from a Python code step | Python | Same language, standard library included |
| A rule used in many flows | Rhai | Transform Modules: write once, import everywhere |
| Totals or summaries over large record sets | Rhai | Batched step and finish |
| A parser or library shared by flows and AI agents | WebAssembly module | Compiled, reusable, callable as an agent tool |
| A script that needs packages, files or other programs | A script over SSH on your own server | Runs with what that host has installed |
WebAssembly for reusable modules
Some logic is bigger than a script: reading a raw email and its attachments, parsing a fixed-width bank file, or redacting personal data before text reaches an AI model. For that, Neblex runs WebAssembly modules, small compiled files that take JSON in and return JSON out.
A module is written once, in Rust or another language that compiles to WebAssembly, and reused by any flow or called by an AI agent as a tool. It runs sandboxed like a Code step, with no access to files or the network. Modules are included in the Business and Enterprise plans. Our WebAssembly post covers the library we published.
Business rules that stay in code
These scripts from our migration test should stay in code, because each one is a rule specific to one business. Each ran in a Code step with only a transform wrapper added, and gave the same output as the original script on every record.
| Script | Language and mode | What it does | Result |
|---|---|---|---|
| Pricing rules | JavaScript, Each record | Price list, segment and volume discounts, promo codes and a price floor | 5 order lines priced; an unknown SKU and an invalid promo code flagged |
| Lead scoring | JavaScript, Each record | Weighted points for email domain, job title, company size, country and demo requests, then a grade | Scores of 100, 65, 32 and 0, graded A, B, D and D, with the reasons listed |
| Shipping allocation | JavaScript, All records | Splits orders into lines and shares out shipping by line value | 2 orders became 4 lines; $12.50 of shipping split $6.25, $5.12 and $1.13 |
| Invoice totals | Python, Each record | Exact money math with decimal, discounts and tax by region | Totals of 314.73, 27.86 and 1,000.00; an unknown region flagged |
| Address parser | Python, Each record | Splits a one-line US or Canadian address into street, unit, city, region and postal code | 3 addresses parsed; 1 that couldn't be parsed flagged |
| Order validation | JavaScript and Python, All records | 32 rules plus reference tables for 183 countries, US states, Canadian provinces, currencies and postal-code formats | Identical results in both languages |
Data also moves cleanly between languages. In a separate flow that passed records through Rhai, JavaScript, and Python steps in turn, every field each language added arrived intact in the next step. Numbers stayed numbers, and booleans and nested objects kept their types.
What code can't reach, and why that helps
In both JavaScript and Python, I tried to step outside the sandbox. Every attempt failed:
| What I tried | Python | JavaScript |
|---|---|---|
| Read or write a file, list a folder | Failed: no file system | No file functions available |
| Read environment variables | None present | No process object |
| Open a network connection or HTTP request | No network support | No fetch or require |
| Start a process | Not available | Not available |
| Random numbers | Seeded per run: a retry or replay repeats them | Seeded per run: a retry or replay repeats them |
The practical effect is that a Code step can only transform the records it is given. A script written by an AI assistant, copied from a forum, or inherited from a colleague can't send your data anywhere or read a credential. Connector steps make calls to other systems, using the connections you set up in Neblex.
This has a second benefit. A script's clock is fixed at its run's start and its random numbers are seeded per run, so a retry or replay of a run gets the same output from each Code step, which makes replaying a failed step safe.
Going past the sandbox
A Code step is more restricted than JavaScript in a browser tab, which can at least make web requests. That is deliberate. When a job needs more, Neblex offers two other options, so the Code step itself never gets access to files or the network.


The first is a WebAssembly module, described above: compiled logic you reuse across flows and AI agents, still sandboxed.
The second is a script on a server you control, run over the SSH connector. The connector runs a command, or a Bash, shell, Python, or PowerShell script, on that host, usually through an On-Prem Worker inside your network. There, the script has whatever the host has: installed packages, files, and other programs.
I tested this against a Linux test server. A flow ran a Python script over SSH that imported the requests package, read a system file, ran a shell command, and wrote its result to a file, all things a Code step refuses to do. The script runs with that host's permissions, so set it up like any other server job: a dedicated user with only the access the script needs.
Moving code steps from another platform
When I help customers move code, these are the changes we make:
- Check whether a built-in step does the job. Often one does, and the script goes away.
- Wrap the logic in
transform(item)ortransform(items), take inputs from the record, and return the record. - Move API calls out of the script and into connector steps before or after it.
- Replace packages with the standard library, or move that logic into a WebAssembly module.
- If logic is copied into several flows, move it into a Rhai Transform Module or a WebAssembly module so there is one copy to fix.
For the rare script that needs packages or access to a server, run it over SSH on your own host instead, as described above.
What we found moving 31 scripts
The first question is the same as above: does this step need to be code at all? Of the 31 scripts we moved, 17 became built-in steps, 8 ran unchanged with only transform added, and 6 needed one change. Each of those six changes involved something outside the script's logic, such as an API call, an npm package, stored state, random IDs, or SQL built from strings.
Larger workflows follow the same pattern. We rebuilt two workflows from another automation platform's public template library whose logic lived in JavaScript code steps. A paginated API import of 11 steps, 3 of them code, became 5 steps with no code, using the HTTP step's built-in paging and retry settings.
The original's retry setting was never used, so one failed page silently cut the import short. A data-quality scoring job became Edit text, Remove duplicates, Filter, and Group & summarize steps, with SQL only to read and write rows and for one statistics query. Neither rebuild needed a code step.
What can go wrong
- Money calculated in JavaScript can be off by a fraction of a cent. Use integer cents, or Python's
decimal. - Returning
nullorNonedrops a record without an error. Compare the record count before and after the step when you test it. - A script that worked in a tool with network access may have hidden API calls. Search for
fetch,requests, andhttpbefore you move it. - Long scripts copied between flows drift apart. Move shared rules into a module.
- Normalize puts email addresses in standard form but keeps the part before the @ as written, which the email standard allows. For a duplicate check that ignores case, add an Edit text step that lowercases the address before Remove duplicates.
The takeaway
Start with the built-in steps, wherever possible. When you do need code, choosing between a Python or JavaScript code step comes down to who maintains it and what the job needs: JavaScript for reshaping records and Node-based code, Python for exact math and its standard library, Rhai for reusable rules, and WebAssembly for modules shared by flows and agents. All of them run sandboxed in Neblex, so pick for the people and the job, keep I/O in connector steps, and run a script that needs more than the sandbox allows over SSH on a server you control.
Sources
- decimal: Decimal fixed-point and floating-point arithmetic, Python 3.11 documentation
- statistics: Mathematical statistics functions, Python 3.11 documentation
- Floating-point arithmetic: issues and limitations, Python tutorial
- The Python Standard Library, Python 3.11 documentation
- Number, MDN Web Docs
- The Rhai Book, Rhai
- Security, WebAssembly.org
Last checked: November 30, 2026.
Frequently asked questions
Should I use Python or JavaScript in a workflow code step?
First check whether a built-in step does the job, because much of what needs a script in other tools doesn't in Neblex. If you need code, use the language your team reads most easily: JavaScript for reshaping JSON records and code moved from Node-based tools, Python for exact money math, statistics, and text checks, with decimal, statistics, and re in its standard library. For small rules you want to reuse across flows, use Rhai.
Can a code step call an API or read a file?
Not in Neblex: JavaScript, Python, and Rhai Code steps run in a sandbox with no file, network, or process access and no environment variables. They work only on the records the step receives. Calls to other systems go in connector steps, which use the connections you set up in Neblex.
Can I use pip or npm packages in a Neblex code step?
No. Python Code steps have the Python 3.11 standard library, without its modules for files, the network and processes, and JavaScript Code steps have the language itself, with no require or npm packages. For logic that needs a library, build a WebAssembly module, or run a script over the SSH connector on your own server.
Will my code from another automation tool run in Neblex?
Most transformation logic ports with small changes: wrap it in a transform function, take inputs from the record, and return the record. Code that calls APIs or imports packages needs to change, so move the API calls into connector steps. When we moved 31 scripts in our test, 8 ran unchanged, 6 needed one change like this, and 17 were replaced with built-in steps.
Bring us the product or the integration that hurts most
We will build it with you, on your data, with the run log open.