Convert n8n automation workflow JSON files into clean, executable Python scripts — instantly.
You have an n8n workflow like this:
[Schedule] → [HTTP Request] → [Send Slack Message] Run one command:
python converter.py my_workflow.jsonAnd get a ready-to-run Python file:
import schedule, time, requests from slack_sdk import WebClient def run_every_day_at_9am(): response = requests.get("https://api.example.com/data") data = response.json() client = WebClient(token=os.getenv('SLACK_TOKEN')) client.chat_postMessage(channel="#general", text=str(data)) schedule.every().hour.do(run_every_day_at_9am) while True: schedule.run_pending() time.sleep(60)| Category | Nodes |
|---|---|
| Triggers | Manual, Schedule, Webhook |
| Logic | IF, Switch, Merge, Set |
| HTTP | HTTP Request |
| Code | Code, Function |
| Services | Slack, Gmail, Airtable, PostgreSQL, MySQL, Notion |
| AI / LLM | OpenAI, Anthropic/Claude |
| Everything else | Generic fallback with TODO comments |
git clone https://github.com/yourusername/n8n-workflow-to-python cd n8n-workflow-to-python pip install -r requirements.txtNo external libraries are needed for the converter itself — only for the generated scripts (e.g. requests, slack-sdk, etc.).
Basic:
python converter.py workflow.jsonCustom output filename:
python converter.py workflow.json -o my_automation.pyVerbose mode (shows all nodes and connections before converting):
python converter.py workflow.json --verboseHelp:
python converter.py --help- Try the included example:
python converter.py examples/slack_alert.json --verbose- This produces
slack_daily_alert.py— open it, fill in your credentials, run it.
The converter has 6 steps:
- Load — reads the JSON file with
json.load() - Extract nodes — parses each node's
name,type, andparameters - Extract connections — builds the execution flow from node to node
- Map types — looks up each node type in a templates dictionary
- Generate code — calls the matching generator function per node
- Write file — outputs a complete, formatted Python script
Each n8n node type has its own generator function (e.g. _gen_http_request, _gen_slack_node). Adding support for a new node type means adding one function.
Generated scripts use os.getenv() for credentials. Create a .env file:
SLACK_TOKEN=xoxb-your-token OPENAI_API_KEY=sk-your-key ANTHROPIC_API_KEY=sk-ant-your-key GMAIL_USER=you@gmail.com GMAIL_PASSWORD=your-app-password AIRTABLE_TOKEN=pat-your-token DATABASE_URL=postgresql://user:pass@localhost/db NOTION_TOKEN=secret_your-tokenInstall python-dotenv and the script loads it automatically:
pip install python-dotenvn8n-workflow-to-python/ ├── converter.py ← Main converter (single file, no dependencies) ├── requirements.txt ← Optional packages for generated scripts ├── examples/ │ └── slack_alert.json ← Sample n8n workflow to test with └── README.md Want to add support for more node types? It's easy:
- Add a new function
_gen_yournode(node)that returns a list of Python code lines - Add it to the
NODE_TEMPLATESdict with the node's type string
Example:
def _gen_telegram_node(node): return [ "# Telegram — send message", "import requests", f"requests.post(f'https://api.telegram.org/bot{{os.getenv(\"TELEGRAM_TOKEN\")}}/sendMessage', ...)", ] NODE_TEMPLATES["n8n-nodes-base.telegram"] = _gen_telegram_nodeMIT © 2024
Built to make 2055+ n8n workflows accessible as Python code.