Transform Structured Text into visual ladder diagrams.
Simulate PLC logic in real-time. All in your browser.
β‘ Live Demo Β β’Β π Documentation Β β’Β Quick Start Β β’Β Features Β β’Β Architecture
| Desktop | Mobile |
![]() |
![]() |
Write IEC 61131-3 Structured Text code. Watch it transform into ladder diagrams instantly. Run live simulations with scan cycle execution. Toggle inputs. Watch outputs change. Debug visually.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β ST Code Ladder Diagram Variable Watch β
β ββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β IF A AND β βββΊ β ββ€Aβββ€Bββ(Y) β βββΊ β A: [TRUE ] β β
β β B THEN β β β β B: [FALSE] β β
β β Y := 1; β β Power flows β β Y: [FALSE] β β
β ββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β
β Write code See it visualized Simulate & debug β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
Write ST code and watch the ladder diagram update instantly. Full bidirectional sync keeps everything in harmony. TON (On-Delay), TOF (Off-Delay), TP (Pulse) β all IEC 61131-3 compliant with proper timing behavior. CTU (Count Up), CTD (Count Down), CTUD (Up/Down) β complete with preset values and output flags. |
R_TRIG (Rising Edge), F_TRIG (Falling Edge) β single-scan pulse generation for event-driven logic. Run your ladder logic with real scan cycle execution. Toggle inputs, watch outputs respond, observe timer elapsed times. Monitor all variables in real-time. Click to toggle BOOLs. View timers and counters. Filter by type. |
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Category β Supported Elements β
ββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Boolean Logic β AND, OR, XOR, NOT β
β Comparisons β =, <>, >, >=, <, <= β
β Arithmetic β +, -, *, /, MOD β
β Control Flow β IF/THEN/ELSIF/ELSE, CASE, FOR, WHILE, REPEAT β
β Timers β TON, TOF, TP β
β Counters β CTU, CTD, CTUD β
β Edge Detectors β R_TRIG, F_TRIG β
β Data Types β BOOL, INT, REAL, TIME β
β Variable Sections β VAR, VAR_INPUT, VAR_OUTPUT, VAR_IN_OUT β
ββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Clone the repository
git clone https://github.com/cdilga/ladder-logic-editor.git
cd ladder-logic-editor
# Install dependencies
npm install
# Start development server
npm run devOpen http://localhost:5173 and start writing ST code!
PROGRAM TrafficController
VAR_INPUT
START_BTN : BOOL; (* Start button *)
STOP_BTN : BOOL; (* Stop button *)
ESTOP : BOOL; (* Emergency stop *)
END_VAR
VAR_OUTPUT
N_RED : BOOL; (* North Red *)
N_YEL : BOOL; (* North Yellow *)
N_GRN : BOOL; (* North Green *)
END_VAR
VAR
Running : BOOL;
PhaseTimer : TON;
CurrentPhase : INT;
END_VAR
(* Start/Stop Logic *)
IF START_BTN AND NOT ESTOP THEN
Running := TRUE;
END_IF;
IF STOP_BTN OR ESTOP THEN
Running := FALSE;
END_IF;
(* Phase Timer - 3 second phases *)
PhaseTimer(IN := Running, PT := T#3s);
IF PhaseTimer.Q THEN
CurrentPhase := CurrentPhase + 1;
IF CurrentPhase > 2 THEN
CurrentPhase := 0;
END_IF;
END_IF;
(* Output Logic *)
N_GRN := Running AND CurrentPhase = 0;
N_YEL := Running AND CurrentPhase = 1;
N_RED := Running AND CurrentPhase = 2;
END_PROGRAM
βββββββββββββββββββββββββββββββββββββββ
β Transformation Pipeline β
βββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β βββββββββββ βββββββββββ βββββββββββ βββββββββββ β
β β ST β β Lezer β β Ladder β β React β β
β β Code βββββΊβ AST βββββΊβ IR βββββΊβ Flow β β
β βββββββββββ βββββββββββ βββββββββββ βββββββββββ β
β β β
β "IF A THEN" Typed syntax Rungs, contacts Visual β
β " Y := 1" tree nodes coils, branches diagram β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββ΄ββββββββββββββββ
β β
βββββββββΌββββββββ βββββββββΌββββββββ
β Interpreter β β Layout β
β & Simulator β β Engine β
βββββββββββββββββ βββββββββββββββββ
β β
Scan cycle execution Node positioning
Timer/Counter state Edge routing
Variable updates Branch layout
| ST Expression | Ladder Representation |
|---|---|
A AND B |
Series contacts: ββ€Aβββ€Bββ |
A OR B |
Parallel branches |
NOT A |
Normally Closed: ββ€/Aββ |
X := expr; |
Input contacts β Output coil |
TON(IN:=x, PT:=T#5s) |
Timer function block |
CTU(CU:=x, PV:=10) |
Counter function block |
Count > 10 |
Comparator block |
| Technology | Purpose |
|---|---|
| React 19 | UI framework with concurrent features |
| TypeScript | Type safety across the codebase |
| Vite | Fast builds and HMR |
| React Flow | Ladder diagram rendering |
| CodeMirror 6 | ST code editor with syntax highlighting |
| Lezer | High-performance parser generator |
| Zustand | Lightweight state management |
src/
βββ components/
β βββ ladder-editor/ # Ladder diagram canvas & nodes
β β βββ nodes/ # Contact, Coil, Timer, Counter nodes
β βββ st-editor/ # CodeMirror ST editor
β βββ variable-watch/ # Real-time variable monitoring
β βββ layout/ # App layout components
βββ transformer/
β βββ ast/ # ST AST types & CST conversion
β βββ ladder-ir/ # Intermediate representation
β βββ layout/ # Diagram positioning algorithm
β βββ react-flow/ # IR to React Flow conversion
βββ interpreter/
β βββ program-runner.ts # Scan cycle execution
β βββ expression-evaluator.ts
β βββ statement-executor.ts
β βββ function-block-handler.ts
βββ lang/
β βββ st.grammar # Lezer grammar for ST
βββ store/
βββ project-store.ts # Project state
βββ simulation-store.ts # Simulation state & variables
# Run unit tests
npm test
# Run with watch mode
npm run test:watch
# Run E2E tests
npm run test:e2eThe project includes:
- Unit tests for parser, transformer, and interpreter
- Property-based tests for arithmetic and control flow
- Compliance tests for IEC 61131-3 conformance
- Integration tests for real-world PLC patterns
- E2E tests with Playwright
Automatically deployed to GitHub Pages on every push to main.
Live site: https://lle.dilger.dev/
- User Guide β Tutorials and getting started
- IEC 61131-3 Reference β Full standard specification
MIT License β use freely for personal and commercial projects.
Built with β and a passion for industrial automation

