Convert n8n workflow JSON into runnable Python projects.
Documentation · Report a Bug · Request a Feature
nCode is an open-source transpiler that takes exported n8n workflows and generates a Python project you can run immediately.
Key outcomes:
- Converts n8n nodes into Python code with a deterministic pipeline.
- Auto-detects output mode:
- FastAPI mode for webhook/chat-triggered workflows.
- Script mode for manual/schedule or non-HTTP workflows.
- Generates project artifacts you can run/share:
main.pyrequirements.txt.env.exampleREADME.mdworkflow_meta.json
- Preserves unsupported nodes as explicit TODO stubs instead of failing the full generation.
Backend pipeline flow:
- Parse JSON into Pydantic models.
- Build a DAG from workflow nodes and connections.
- Topologically order executable nodes.
- Detect output mode (
fastapiorscript) from trigger node types. - Dispatch per-node handlers to emit IR.
- Emit Python source from IR.
- Run post-processing (black + isort + syntax checks).
Core folders:
backend/core/: graph, IR, expression translation, emitter, pipeline.backend/handlers/: one handler class per node type family.backend/models/: request/response and workflow Pydantic models.backend/routers/: FastAPI router endpoints.frontend/src/: React + Vite user interface.docs/: project documentation site content.
The registry currently exposes 107 supported node-type strings (including aliases and specialized LangChain node types).
For the exact runtime list in your local checkout:
- Use API endpoint:
GET /api/supported-nodes - Or inspect handlers under
backend/handlers/
Design principle:
- Supported nodes generate concrete Python blocks.
- Unsupported nodes still produce runnable pass-through stubs with TODO comments.
- Python 3.10+
- Node.js 18+
- Docker 24+ (optional)
git clone https://github.com/opsingh861/nCode.git
cd nCode
# Backend environment
cd backend
python -m venv .venv
# Windows PowerShell
.\.venv\Scripts\Activate.ps1
# macOS/Linux
# source .venv/bin/activate
cd ..
pip install -r requirements.txt
# Optional environment customization
# Windows PowerShell: Copy-Item .env.example .env
# macOS/Linux: cp .env.example .env
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000Open API docs at http://localhost:8000/docs.
From repo root:
./run-dev.shThis starts:
- backend at
http://0.0.0.0:8000 - frontend at
http://localhost:3000
Note: the script expects backend Python at backend/.venv/Scripts/python.exe.
docker compose up --buildServices:
- frontend:
http://localhost:3000 - backend API:
http://localhost:8000 - OpenAPI docs:
http://localhost:8000/docs
| Method | Endpoint | Purpose |
|---|---|---|
GET |
/ |
Health check |
POST |
/api/upload |
Upload workflow.json, run pipeline, return generated preview + download_id |
GET |
/api/download/{download_id} |
Download generated ZIP for a previous upload |
POST |
/api/generate |
Direct JSON transpilation endpoint (no multipart upload) |
GET |
/api/supported-nodes |
Get all registered node type strings |
Upload flow:
curl -X POST "http://127.0.0.1:8000/api/upload" -F "file=@workflow.json"Download artifact:
curl -L "http://127.0.0.1:8000/api/download/<download_id>" -o workflow_python.zipDirect JSON generate flow:
curl -X POST "http://127.0.0.1:8000/api/generate" \
-H "Content-Type: application/json" \
--data @workflow.jsonThe UI is built with React + TypeScript + Vite and proxies /api calls to http://localhost:8000 in development.
cd frontend
npm install
npm run devSee CONTRIBUTING.md for full guidelines. Common local checks:
# Tests
backend\.venv\Scripts\python.exe -m pytest backend/tests/ -v
# Formatting checks (CI-aligned)
backend\.venv\Scripts\python.exe -m black --check backend/
backend\.venv\Scripts\python.exe -m isort --check-only --profile black backend/- Create or update a handler file in
backend/handlers/. - Register node types with
@register("node.type"). - Implement the handler interface (
generate,supported_operations,required_packages). - Import the module in
backend/handlers/__init__.pyso registration runs.
- Credentials are emitted as environment variable lookups (
os.getenv(...)) rather than embedded secrets. - Upload flow enforces JSON extension and file size constraints.
- Download IDs are UUID-validated to prevent path traversal.
- Temporary artifact cleanup runs during app lifecycle shutdown.
- CORS origins are explicit (configured by
CORS_ALLOW_ORIGINSor safe local defaults).
nCode/
|-- backend/
| |-- core/
| |-- handlers/
| |-- models/
| |-- routers/
| `-- main.py
|-- frontend/
| `-- src/
|-- docs/
|-- requirements.txt
|-- run-dev.sh
`-- docker-compose.yml
- Docs site: https://opsingh861.github.io/nCode/
- Architecture: docs/architecture.md
- Getting started: docs/getting-started.md
- Node handlers: docs/node-handlers.md
- API reference: docs/api-reference.md
MIT. See LICENSE.
