Stop Dragging Nodes: Build n8n Workflows with Claude Code or Codex Instead

Blog / Stop Dragging Nodes: Build n8n Workflows with Claude Code or Codex Instead

Stop Dragging Nodes: Build n8n Workflows with Claude Code or Codex Instead

Share

Short version: an n8n workflow is a JSON document, not a drawing. Any AI coding agent that can write JSON can therefore write an entire workflow — nodes, connections, expressions, error branches and all. Describe the automation in plain English to Claude Code or OpenAI Codex, paste the generated JSON into the n8n canvas with Ctrl+V, and a build that takes 40 minutes of dragging takes about three minutes — with far fewer broken expressions.

We teach this method in class because it changes what a beginner can ship on day one. Below is the full workflow-as-code method, a prompt template you can copy, the failure modes to watch for, and how to self-host n8n cheaply so you are not paying per execution while you experiment.

Why manual node-dragging is the slow, error-prone path

Building in the n8n GUI feels productive because you can see the workflow forming. But most of the real time goes somewhere else entirely: looking up which node does the thing you want, guessing the exact shape of the data coming out of the previous node, and typing expressions like {{ $json.body.items[0].email }} from memory. Get one character wrong and the node fails at runtime with a message that points at the symptom, not the cause.

TaskManual GUI buildGenerated with Claude Code / Codex
12-node workflow, first draft30-60 minutes2-5 minutes
Expression syntax errorsCommon — typed by hand, found at runtimeRare — the model has seen thousands of valid expressions
Node discoveryManual search through 400+ nodesThe model proposes the node
Error handling branchesUsually skipped "for now"Ask for it once, included every time
Documenting the workflowRarely doneSticky notes generated inline
Version controlManual export, if you rememberThe JSON is already in your repo

The last row is the one people underestimate. When workflows live as JSON files in a Git repo, you get diffs, code review, rollback and branching for your automations — the things software teams have had for thirty years and automation teams generally have not.

The key insight: an n8n workflow is just JSON

Open any workflow in n8n, press Ctrl+A then Ctrl+C, and paste into a text editor. You get a JSON object with two parts that matter:

  • nodes — an array where every node has a name, a type (for example n8n-nodes-base.httpRequest), a position as [x, y], and a parameters object holding its settings.
  • connections — an object mapping each node name to the nodes its output feeds into.

That is the entire format. And critically, the reverse works too: copy valid workflow JSON to your clipboard, click on the n8n canvas and press Ctrl+V, and n8n renders it as a live workflow. This clipboard round-trip is the whole trick. It means any tool that can produce correct JSON is a legitimate n8n workflow builder.

Method 1: Claude Code (best for repo-based, multi-workflow projects)

Claude Code runs in your terminal, reads and writes files in your project, and can iterate on its own output. That makes it the strongest option when you are building a set of related workflows and want them under version control.

  1. Create a project folder and start Claude Code inside it:
    mkdir n8n-workflows && cd n8n-workflows
    git init
    claude
  2. Export one workflow you already trust from n8n and save it as examples/reference.json. This single example is the highest-leverage thing you can do — it shows the model your n8n version's exact node types and parameter shapes.
  3. Ask for the workflow in plain English (prompt template below). Claude Code writes it to a .json file in the folder.
  4. Open the file, select all, copy, then click the n8n canvas and press Ctrl+V.
  5. Add your credentials in the n8n UI — never in the JSON — and run the workflow.
  6. When something misbehaves, paste the n8n error message back to Claude Code and ask it to fix the specific node. It edits the file in place; re-paste and re-test.

Because everything is a file, you can then git commit each working version, and ask Claude Code things like "create a variant of this that reads from Google Sheets instead of Airtable" — which takes seconds instead of a rebuild.

If you want to learn this workflow properly — the file conventions, custom commands, and how to drive it for real automation projects — that is exactly what our Claude Code Masterclass covers, and it sits inside the broader Claude AI Series of hands-on courses. Singaporeans can offset the fee with SkillsFuture Credit.

Method 2: OpenAI Codex (best for fast one-off workflows)

Codex works well when you want a single workflow generated quickly, either from the CLI or the web interface. The method is the same, minus the repo scaffolding:

  1. Paste in one exported example workflow as your format reference.
  2. Describe the automation you want, including the trigger, each step, and what happens on failure.
  3. Ask for the complete workflow JSON only, no commentary — so you can copy the whole response straight to the clipboard.
  4. Paste onto the n8n canvas, attach credentials, test.

In practice, teams use both: Codex for quick throwaway automations, Claude Code when the workflows become a maintained asset. Our Codex Masterclass and Codex for Work Automation courses — both part of the Codex AI Series — teach the CLI, the prompting discipline and the review habits that keep generated code trustworthy.

The prompt template that actually works

Vague prompts produce plausible-looking workflows that fail on the first run. The fix is to specify the trigger, the data shape and the failure path explicitly. Copy this:

You are generating an n8n workflow as JSON.

FORMAT REFERENCE
Here is an exported workflow from my n8n instance. Match this
structure, node type names and parameter shapes exactly:
<paste your exported example JSON here>

WORKFLOW TO BUILD
Trigger: [e.g. Webhook, POST, path /new-lead]
Steps:
  1. [e.g. Validate that email and name are present]
  2. [e.g. Look up the company domain via HTTP Request]
  3. [e.g. Append a row to Google Sheets]
  4. [e.g. Send a Slack message to #sales]
On failure: [e.g. route to a Slack alert in #ops with the error]

RULES
- Do NOT include any credentials, API keys or tokens.
  Leave credential fields empty; I attach them in the UI.
- Use n8n expression syntax for referencing prior node data.
- Add Sticky Note nodes explaining each section.
- Lay nodes out left to right, ~220px apart, so it is readable.
- Output ONLY the workflow JSON. No explanation before or after.

Three details in that template do most of the work. The format reference pins the model to your n8n version. The credentials rule keeps secrets out of files and chat logs. And "output ONLY the JSON" means you can select-all-copy without manually stripping prose — which matters because a stray sentence makes the clipboard paste fail silently.

What still goes wrong (and how to fix it fast)

SymptomCauseFix
Paste does nothing on the canvasThe clipboard contains prose around the JSONCopy only from the first { to the last }
"Unknown node type"The model invented a node, or your n8n is older than it assumesGive it your exported example and your n8n version number
Node runs but data is emptyExpression references a field name that does not existRun the prior node, copy the real output JSON, paste it back to the agent
Credentials errorCredentials are never in the JSON, by designSelect the credential in each node in the n8n UI
Nodes stacked on top of each otherPositions not specifiedAsk for left-to-right layout ~220px apart

The pattern behind every one of these: the agent cannot see your n8n instance. Every time you hand it real data — an exported workflow, an actual error message, a genuine sample payload — accuracy jumps. Treat it as a very fast collaborator who is working blind, and feed it eyes.

You need your own n8n to do this properly

Generating workflows means running a lot of test executions, and installing community nodes the model suggests. On n8n Cloud that burns your execution quota and community nodes are restricted. Self-hosting removes both limits — flat monthly cost, unlimited executions, and your credentials sit in your own database rather than a vendor's. For anyone handling client data under PDPA, that last point is usually the decider.

How to install n8n on a Hostinger VPS (the quick version)

Hostinger is the cheapest reliable route we have found: VPS plans start around a few dollars a month, the servers are fast, and there is a one-click n8n template so you do not have to configure Docker yourself. The short path:

  1. Order a Hostinger VPS — the 2 GB plan is the sensible starting point for n8n.
  2. In the setup wizard, choose the operating system by application and pick the n8n template instead of a bare Ubuntu image.
  3. Set a strong root password and let it provision — it takes a few minutes.
  4. Point a subdomain (for example n8n.yourdomain.com) at the VPS IP with an A record.
  5. Open https://your-subdomain, create the owner account, and enable HTTPS — the template provisions a free Let's Encrypt certificate once the DNS resolves.
  6. Turn on basic auth and take a first backup before you put anything real through it.

Prefer to do it manually with Docker? Hostinger's own step-by-step n8n installation tutorial walks through both routes, and our earlier guide, How to Install n8n on a Hostinger VPS, covers the Docker commands, the Nginx reverse proxy and the security hardening most tutorials skip.

Here is the whole setup on video, including HTTPS and backups:

Get 20% off your Hostinger VPS with our referral link — it costs you nothing extra and supports these free tutorials.

A sensible working setup

  1. Self-hosted n8n on a VPS — your execution engine, unlimited runs.
  2. A Git repo of workflow JSON files — your source of truth, diffable and reviewable.
  3. Claude Code or Codex in that repo — your builder, with one exported workflow as the format reference.
  4. Credentials only in the n8n UI — never in files, never in a chat window.

That is the setup we run in the classroom, and it is what makes it realistic for someone with no automation background to ship a working multi-step workflow on their first day.

Learn this properly, with funding

Reading about it gets you the concept; building three or four real workflows with someone correcting your prompts gets you the skill. Three routes depending on where you are starting:

Browse the full Claude AI Series and Codex AI Series to see every course and the next available dates.

Frequently asked questions

Can Claude Code really build a working n8n workflow from a description?

Yes, reliably, provided you give it one exported workflow from your own n8n as a format reference. Without that reference it guesses at node type names and parameter shapes, and you get a workflow that pastes but does not run. With it, a 10-15 node workflow generated on the first attempt usually needs only credential attachment and one or two small corrections.

Is Codex or Claude Code better for n8n workflows?

Codex is quicker for a single throwaway workflow. Claude Code is better when workflows become a maintained asset, because it works inside a project folder — it can read your existing workflow files, edit them in place, and keep everything in Git. Many teams use both. We teach both in the Claude AI Series and Codex AI Series.

How do I import the generated JSON into n8n?

Copy the JSON to your clipboard, click anywhere on an open n8n canvas, and press Ctrl+V (Cmd+V on Mac). n8n parses the clipboard and renders the nodes. Alternatively use Workflows → Import from File. If nothing appears when you paste, your clipboard almost certainly contains explanatory text around the JSON — copy only from the first opening brace to the last closing brace.

Should I put my API keys in the workflow JSON?

No, never. n8n stores credentials separately from workflow definitions precisely so that workflows can be shared and version-controlled safely. Always leave credential fields empty in generated JSON and attach the credential in the n8n UI. This also keeps your keys out of your AI chat history and out of your Git repo.

Is self-hosted n8n free?

The n8n Community Edition is free to self-host under a fair-code licence, so your only cost is the server. On a Hostinger VPS that is a few dollars a month for unlimited workflow executions, which is why it works out far cheaper than a metered cloud plan once you are running real automations daily.

Can I claim SkillsFuture Credit for these courses?

Yes. Our non-WSQ AI courses, including the Claude Code and Codex masterclasses, are SkillsFuture Credit claimable for eligible Singaporeans. The WSQ n8n and Claude Code courses additionally carry up to 70% SSG course-fee funding, with Absentee Payroll available to employers sponsoring their staff. Eligibility is shown on each course page.

Do I need to know how to code to use this method?

No. You are writing an English description of the automation, not code — the agent produces the JSON. What you do need is the ability to read an error message and hand it back to the agent, and the discipline to test each workflow before trusting it. Both are taught in class from a standing start.

Next steps

  1. Spin up a Hostinger VPS at 20% off and install n8n with the one-click template
  2. Export one working workflow as your format reference
  3. Generate your next workflow with the prompt template above instead of dragging nodes
  4. Book a Claude AI Series course or a Codex AI Series course and build it properly — with SkillsFuture Credit or up to 70% WSQ funding

Disclosure: the Hostinger links in this article are referral links — using them costs you nothing extra and gets you 20% off, while supporting our free tutorials. Tooling in this space moves fast; check the official Claude Code, Codex and n8n documentation for the latest commands.