CPN IDE for VS CodeDraw, validate and simulate Coloured Petri Nets without leaving VS Code. The extension runs
CPN IDE, the successor of CPN Tools, in an editor tab: open a Nothing to install first: the CPN IDE backend, UI and simulator ship with the extension, and a Java 17 runtime is downloaded on first use if you don't already have one.
Features
Getting startedAfter installing, the Get Started with CPN IDE walkthrough opens on the Welcome page (also available via Help → Welcome or Welcome: Open Walkthrough). It opens an example, runs a simulation and creates your first net, step by step.
The CPN IDE icon in the Activity Bar opens a sidebar with three views:
The backend controls are in the status bar menu (click the CPN IDE item): Start/Restart, Stop, Show Log, Settings,
and the Docker actions (on macOS, when A To start from scratch, run CPN IDE: New Net from the Command Palette ( Simulating a modelClick Start simulation in the CPN IDE toolbar. Enabled transitions are highlighted in green; click one to fire it, or use the Simulation panel on the left:
The current marking of each place is shown next to it (for example
Multi-step runs wait 100 ms between steps by default. Lower For a quick check without the UI, right-click a
Text modelsA net can be written by hand, versioned and diffed like any other source file. A model has two files next to each other:
Keep the JSON in one editor and the canvas in another (CPN IDE: Reopen as XML Text switches a canvas tab back to text). The canvas reloads when either file changes on disk.
Compile errors are reported while you type. When the backend is running and no CPN IDE tab is open, saved models are also type-checked by the simulator.
CPN IDE: Convert to Text Model turns an existing Open
|
| Command | Where | What it does |
|---|---|---|
| CPN IDE: Open Example | Command Palette, walkthrough, sidebar | Copy a bundled example into cpn-examples/ and open it |
| CPN IDE: Open in CPN IDE | ▶ in the editor title, Explorer menu, sidebar | Open a .cpn / .petri.json in the CPN IDE canvas |
| CPN IDE: Reopen as XML Text | editor title | Show the file as text again |
| CPN IDE: New Net | Command Palette, Explorer folder menu, sidebar | Create NAME.petri.json + NAME.sml with a starter net and open it |
| CPN IDE: Convert to Text Model | .cpn editor title, Explorer menu |
Write .petri.json + .sml from a .cpn |
| CPN IDE: Export .cpn | .petri.json editor title, Explorer menu |
Write a .cpn from a text model |
| CPN IDE: Run Simulation (No UI) | Explorer menu, sidebar | Simulate N steps and print the final marking |
| Simulate 100 steps (CodeLens) | top of a .petri.json |
Run 100 headless steps and show each place's final marking inline until you edit the file; Clear results removes it. Also has Open in CPN IDE and Export .cpn lenses |
| CPN IDE: Analyse | Analysis view title, Command Palette | Check the model, run the structural analysis and explore the state space |
| CPN IDE: Check Model / Structural Analysis / Analyse State Space | Command Palette | Run one step of the analysis on its own |
| CPN IDE: Save Analysis Report | Analysis view title, Command Palette | Write the results in the Analysis view to a text file |
| CPN IDE: Run Replications | Analysis view ... menu, Command Palette |
Run N replications and open the replication report |
| CPN IDE: Export Event Log (CSV/XES) | Analysis view ... menu, Command Palette |
Simulate while recording events and write an event log to play_out |
| CPN IDE: Backend Status | status bar, Command Palette | Menu with Start/Restart, Stop, Show Log, Settings and the Docker actions |
| CPN IDE: Show Backend Log | Command Palette, status bar menu | Open the backend and simulator log |
| CPN IDE: Start / Restart / Stop Backend | status bar menu | Start the backend without opening a model, restart it and reload open CPN IDE tabs, or stop it and the simulator |
| CPN IDE: Start Docker Backend | status bar menu, macOS walkthrough | Run the Docker backend as container cpn-ide-backend, set cpnIde.backendUrl and reconnect open tabs |
| CPN IDE: Stop Docker Backend | status bar menu | Stop the cpn-ide-backend container |
Start, Restart, Stop and the Docker commands are not in the Command Palette; use the status bar menu (CPN IDE: Backend Status).
Settings
| Setting | Default | Description |
|---|---|---|
cpnIde.simulation.animate |
true |
Animate tokens moving during simulation |
cpnIde.theme |
auto |
auto makes the canvas, panels and toolbar follow a dark or high-contrast VS Code theme; light always keeps the UI's own light look. Applies when an editor is (re)opened |
cpnIde.codeLens.enabled |
true |
Show the Simulate / Open in CPN IDE / Export .cpn CodeLenses at the top of .petri.json files |
cpnIde.stateSpace.maxStates |
100000 |
Analyse State Space stops after this many states and reports Inconclusive |
cpnIde.stateSpace.timeoutSeconds |
30 |
Analyse State Space stops after this many seconds and reports Inconclusive |
cpnIde.eventLog.* |
Case id, start time, time unit and recorded events of Export Event Log |
Under CPN IDE: Advanced:
| Setting | Default | Description |
|---|---|---|
cpnIde.simulation.stepDelayMs |
100 |
Delay between steps of a multi-step run, in ms (CPN IDE itself uses 500) |
cpnIde.javaPath |
Java 17+ executable. Empty: use JAVA_HOME, java on the PATH, or a downloaded runtime |
|
cpnIde.backendUrl |
URL of an external backend, e.g. the Docker image below. Empty: use the bundled one | |
cpnIde.port |
0 |
Port of the local backend (0 = any free port) |
cpnIde.debug |
false |
Keep the UI's verbose console output in the webview developer tools |
Simulation and debug settings apply when a CPN IDE tab is (re)opened.
Platform support
| Platform | Local simulator | Notes |
|---|---|---|
| Windows x64 | yes | |
| Linux x64 | yes | needs 32-bit glibc: sudo apt install libc6:i386 (Debian/Ubuntu) or sudo dnf install glibc.i686 (Fedora) |
| macOS | no | the CPN simulator is a 32-bit binary; use Start Docker Backend in the status bar menu (see Docker backend) |
Troubleshooting
The CPN IDE item in the status bar shows the backend state: ○ not running, spinning while it starts, ✓ ready, red when the backend or the simulator failed. Click it for the menu: show the log, restart or stop the backend, open the settings, or use the Docker backend.
- "The CPN simulator needs 32-bit glibc" (Linux): the extension checks for
/lib/ld-linux.so.2before starting and shows the install command for your distribution, with Copy command and Use Docker backend buttons. Debian/Ubuntu:sudo dpkg --add-architecture i386 && sudo apt update && sudo apt install libc6:i386; Fedora:sudo dnf install glibc.i686; openSUSE:sudo zypper install glibc-32bit; Arch:sudo pacman -S lib32-glibc(needs multilib); Fedora Silverblue/Kinoite:rpm-ostree install glibc.i686, then reboot. - "The simulator could not start": on Linux, check the 32-bit glibc above. Otherwise click Show Log (or choose it in the status bar menu) to see why.
- "Function not implemented" in
cpnmld.log(VS Code inside a container, Docker 29 or later): the container's default seccomp profile blocks the 32-bit socket call the simulator uses. The Linux VSIX preloads a shim for this (resources/backend/shim); if you built the extension yourself, runscripts/build-sockshim.sh(needsgcc-multilib). - A simulator is already running on port 20001: the CPN simulator always uses this port, so only one can run per machine. A second VS Code window shares the first one's simulator. If a crashed window left one behind, the extension offers to stop it.
- Validation never finishes: after 60 s the extension reports the hang. Choose Stop in the status bar menu and reopen the model.
- Java download blocked (offline or behind a proxy): install a Java 17+ runtime yourself and set
cpnIde.javaPath.
Examples
The examples/ folder has six small models, each
as a text model and as a generated .cpn:
| Model | What it shows |
|---|---|
01-simple-flow |
Three UNIT tokens move from Start to Done; the net stops after 3 steps |
02-producer-consumer |
A counter produces items 1..5 into a buffer (guard [n <= 5]) and a consumer takes them out |
03-mutual-exclusion |
Two processes share one lock, so at most one is ever in Critical |
04-hierarchy |
A Worker subpage behind a substitution transition, with a fusion place shared by both pages |
05-dining-philosophers |
Three philosophers take the left fork, then the right (uncoloured); the net can reach a dead marking |
06-unbounded-producer |
A producer keeps adding tokens to a buffer; it is structurally unbounded, so a state space search hits its cap |
How it works
The extension bundles CPN IDE 1.24.1031 (Java backend and Angular UI) and runs the UI in a VS Code webview. The backend
listens on 127.0.0.1 only. It drives the CPN simulator daemon (cpnmld, fixed port 20001), which compiles and runs
the model's SML code. The extension patches the daemon to listen on 127.0.0.1 only, runs it in a private per-user temp
directory, and stops it, with its workers, when the backend stops or VS Code exits. Daemons left by a crashed VS Code
are cleaned up on the next start. Requests that create a net go through a small local proxy that runs them one at a
time, because two at once can hang the upstream backend.
Docker backend
On macOS, or to keep the simulator off your machine, choose Start Docker Backend in the status bar menu (or from the macOS walkthrough). It starts the image as the container cpn-ide-backend on a free local port, sets cpnIde.backendUrl (workspace or user) and reconnects open tabs. It offers once to stop the container when VS Code exits, and on macOS it is also offered the first time you open a model. Docker must be installed and running. Stop Docker Backend in the same menu stops the container.
Manually:
docker run -p 8080:8080 ghcr.io/alefire99/cpn-ide-backend:latest
Then set cpnIde.backendUrl to http://localhost:8080.
Contributing
Bug reports and ideas are welcome in the issue tracker. See
CONTRIBUTING.md for the development setup. We use Git Flow: work on feature/* branches, open PRs
into develop.
License
AGPL-3.0, same as upstream CPN IDE. See THIRD_PARTY_NOTICES.md.





