A practical field guide from Automation Ace.
Using Python and JavaScript Inside Zapier and Make for Custom Logic
No-code automation handles the majority of business workflows. For the situations where Zapier or Make cannot reach the API you need, see Zapier missing trigger or action workarounds and webhook and API integration consulting. But every complex system eventually reaches a task that no pre-built action can handle: a custom calculation, a data transformation with nested conditions, a string manipulation that requires regex, or a call to an API that does not exist as a connector. That is where a Code step in Zapier or a Code module in Make becomes the right tool — and where knowing a bit of Python or JavaScript pays off immediately.
The code steps in both platforms are not full programming environments. They have limited memory, no filesystem access, and short execution timeouts. But they are exactly right for the tasks they are designed for: transforming data, making decisions based on complex logic, computing values, and calling simple external endpoints. Used correctly, they are the "escape hatch" that makes every automation system capable of handling the real-world edge cases that no-code blocks cannot.
Zapier Code Steps: JavaScript and Python
Zapier offers a "Code by Zapier" action that runs either JavaScript or Python in a sandboxed environment. The step receives data from previous Zap steps as input variables (you map them explicitly in the "Input Data" section), runs your code, and returns an output object that subsequent steps can use as fields.
The input variables section is important to understand: it is not automatic. You must explicitly declare each value you want available in the code step, giving it a name and mapping it to an earlier step's output. A variable named email mapped to the trigger step's email field becomes available in your JavaScript as inputData.email or in Python as input_data['email'].
The output must be a flat key-value object (JavaScript: return {key: value}, Python: return {'key': value}). Nested objects are not supported as output — if your code produces nested data, flatten it before returning.
Practical JavaScript Code Step Examples
- Extracting a domain from an email:
const domain = inputData.email.split('@')[1]; return {domain: domain};— three lines that let you route leads by company domain without a separate enrichment service. - Calculating business days to a due date: Write a function that takes today's date and a due date, counts the weekdays between them, and returns an integer. Use this to set priority (due in under 3 business days = High) in a downstream Zapier step.
- Formatting a name from "Last, First" to "First Last": Form submissions from some CRMs return names in reverse format. One JavaScript replace plus split plus join fixes this before the data lands in your destination system.
- Building a custom JSON payload for a webhook: When calling an API that requires a specific nested JSON structure, build the entire payload as a JavaScript object, then
return {payload: JSON.stringify(result)}and pass it to a Webhooks by Zapier POST step.
Make.com Code Modules: JavaScript Only
Make's Code module runs JavaScript in a Node.js-like environment. It receives the current bundle's data automatically (unlike Zapier, you do not need to explicitly map inputs — all bundle data is available in the bundle object). The module's output becomes available as fields in subsequent modules.
The Code step is not a sign that the no-code platform has failed you. It is the tool that completes the platform — the 5% of logic that every complex system needs and that would otherwise require a custom integration or a full server deployment.
Python in Zapier for Data-Heavy Tasks
Python's standard library access makes it slightly more powerful than JavaScript for certain data manipulation tasks. Useful patterns:
- JSON parsing with error handling: Use
import json; try: data = json.loads(input_data['raw_json']); except: return {'error': 'invalid JSON', 'data': None}to safely parse JSON payloads from upstream steps that might occasionally be malformed. - Date arithmetic:
from datetime import datetime, timedelta; due = datetime.strptime(input_data['due_date'], '%Y-%m-%d') + timedelta(days=7); return {'extended_due': due.strftime('%Y-%m-%d')}— date extension logic in 2 lines. - Regex extraction: Extract a phone number from a messy notes field, pull an order number from an email subject line, or validate that a URL matches a required pattern before passing it downstream.
When scripts outgrow Code steps, host them as serverless functions; see your first Cloudflare Workers API automation.
Calling External APIs from Code Steps
Both Zapier's Code by Zapier and Make's Code module can make HTTP requests. In Zapier JavaScript, use the built-in fetch function: const response = await fetch('https://api.example.com/data', {headers: {'Authorization': 'Bearer ' + inputData.api_key}}); const data = await response.json(); return {result: data.value};. This lets you call APIs that have no Zapier connector without leaving the Zap. Pass the API key as an input variable from a Zapier credential store rather than hardcoding it in the script.
- Add a Code step only after confirming there is no Formatter, built-in action, or existing connector that handles the same task.
- Explicitly map all required input variables in the Code step's Input Data section before writing any code.
- Keep code steps short and single-purpose — if the code step exceeds 30 lines, consider whether the logic should be split across two steps or moved to a standalone function endpoint.
- Return a flat key-value object with clearly named keys so downstream steps are readable.
- Add a try/catch block (JavaScript) or try/except block (Python) and return an error key with a descriptive message when the logic fails — never let an unhandled exception silently drop the record.
- Test the code step in isolation with hardcoded test values before wiring it to real trigger data.
Disclaimer: This article may include links to apps, products, or services. Some links may be affiliate links, which means Automation Ace may earn a commission at no extra cost to you.