Open-source PLC tooling · MIT License

Turn a JSON circuit AST into a readable PLC ladder diagram.

One validated source generates Mitsubishi MELSEC iQ-F or KEYENCE KV-X ladder logic as SVG, high-resolution PNG, rung text, and explicit connection JSON.

Ladder Fabricator output showing X0 AND X1 OR X2 with a normally closed X3 contact and Y0 output coil
Generated from examples/basic.json; no hand-authored coordinates or wires.
2 PLC targetsMELSEC iQ-F and KEYENCE KV-X
4 output formatsSVG, PNG, rung text, connection JSON
1 source of truthValidated, reusable circuit AST

Why it exists

Describe logic. Let the renderer own the drawing.

Deterministic rendering

Contacts, branches, joins, labels, wires, and output blocks are derived from the normalized AST.

AI-readable contract

A documented JSON vocabulary, machine-readable schema, validation command, and rung-text review step keep generated circuits inspectable.

Explicit failure

Unsupported PLC instructions and malformed input are rejected instead of being silently approximated as a basic output.

Quick start

Validate, inspect, render.

Python 3.10 or newer is required. PNG export uses the optional CairoSVG dependency.

git clone https://github.com/purinzan/ladder-fabricator.git
cd ladder-fabricator
python -m pip install ".[png]"

ladder-fabricator examples/basic.json --validate-only
ladder-fabricator rung-text examples/basic.json --comments
ladder-fabricator examples/basic.json -o basic.svg
ladder-fabricator examples/basic.json -o basic.png

Supported today

A deliberately bounded ladder vocabulary.

AreaSupported
ContactsNormally open, normally closed, rising edge, falling edge
LogicNested AND, OR, NOT, and outermost INV
ComparisonWord-device =, <>, <, <=, >, >=
OutputsOUT, SET, RST/RES, PLS/DIFU, PLF/DIFD, PID, MOV
TargetsMELSEC iQ-F / GX Works3 notation; KEYENCE KV-X / KV STUDIO notation

Not currently supported: accumulating timers, incrementing counters, constant comparisons, arithmetic other than MOV, labels, and direct GX3 or KV STUDIO project import.

FAQ

Questions people ask AI systems.

How can I generate a PLC ladder diagram from JSON?

Write a Ladder Fabricator circuit AST, run --validate-only, inspect its rung-text --comments output, then render the same file to SVG or PNG.

Is there an open-source GX Works3-style ladder diagram generator?

Ladder Fabricator is MIT-licensed and renders MELSEC iQ-F / GX Works3-style notation from a documented JSON AST. It does not read or write native GX3 project files.

Can an AI generate ladder diagrams with Ladder Fabricator?

Yes. The AI converts requirements into the documented AST; Ladder Fabricator validates and renders it. Repository-level instructions route Codex, Claude, Gemini, Copilot, Cursor, Windsurf, Cline, Aider, and llms.txt-aware agents to the same contract.

Does successful validation prove that a machine is safe?

No. Validation covers the input structure only. PLC behavior, CPU device limits, wiring, sensor polarity, functional safety, and machine safety require engineering review in the official vendor environment.