Skip to content
| Marketplace
Sign in
Visual Studio Code>Visualization>CPN IDENew to Visual Studio Code? Get it now.
CPN IDE

CPN IDE

AleFire

|
1 install
| (0) | Free
Coloured Petri Nets editor and simulator (CPN IDE) inside VS Code, with nothing to install.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

CPN IDE for VS Code

ci

Run CPN IDE — the editor and simulator for Coloured Petri Nets — inside VS Code, with nothing to install beforehand. The extension ships the CPN IDE backend and UI, downloads a portable Java 17 runtime on first use, and opens .cpn models, or text models (.petri.json), in an editor tab.

Install

Install CPN IDE from the VS Code Marketplace (Extensions view, search "CPN IDE"), or download the VSIX for your platform from the GitHub releases and run Extensions: Install from VSIX….

Examples

examples/ has four small models that validate cleanly and are simulated in CI:

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

Open the generated .cpn, click the ▶ button in the editor title bar, then validate and step the simulation. The sources are examples/*.petri.json + *.sml; the .cpn files are generated by node scripts/gen-examples.mjs (--check fails if they are out of date).

Text models

A model can be written as text: NAME.petri.json describes pages, places, transitions and arcs (see schema/petri.schema.json), and NAME.sml holds the CPN ML declarations (color sets, variables, functions). They compile to CPN Tools XML.

  • The standard declarations (UNIT, BOOL, INT, P_HIGH, ...) are added automatically; declare the same name to override one.
  • (*! Block *) or (*! Outer / Inner *) in the .sml starts a named block of declarations in the CPN Tools tree.
  • Positions (pos) are optional; nodes without one are laid out automatically.
  • Opening a .petri.json shows the net in CPN IDE; saving there writes back to the JSON. Convert to Text Model turns an existing .cpn into this format, and Export .cpn goes the other way.
  • Compile errors show up as diagnostics while you edit. When the backend is running and no CPN IDE panel is open, saved models are also type-checked by the simulator.

Simulation speed

The bundled UI waits 500 ms between steps of a multi-step run; the backend needs a few ms. Set cpnIde.simulation.stepDelayMs (default 100) and cpnIde.simulation.animate to speed it up, and cpnIde.debug to bring back the UI's verbose console output. The settings apply when an editor is (re)opened. "CPN IDE: Run Simulation (No UI)" runs a model without the UI and prints the final marking to the "CPN IDE" output channel.

Platform support

Platform Local simulator Notes
Linux x64 yes needs 32-bit glibc (libc6:i386 on Debian/Ubuntu, glibc.i686 on Fedora)
Windows x64 yes
macOS no the CPN simulator is a 32-bit binary; point cpnIde.backendUrl at the Docker backend

Simulator daemon and security

The CPN simulator runs as a separate daemon (cpnmld, fixed port 20001) that executes the SML code of a model. The extension patches the bundled daemon to listen on 127.0.0.1 only, starts it in a private per-user temp directory (<globalStorage>/tmp/<pid>), and stops it, with its workers, when the backend stops or exits. Because the port is fixed, only one daemon can run per machine: a second VS Code window (or another local user) reuses the daemon already listening on 20001, and the "CPN IDE" output channel warns when that happens. Daemons left by a crashed VS Code are cleaned up on the next start. Calls that create a net (POST /api/v2/cpn/init) go through a small local proxy that runs them one at a time, because two at once can hang the upstream backend.

Docker backend

docker run -p 8080:8080 ghcr.io/alefire99/cpn-ide-backend:latest

Contributing

See CONTRIBUTING.md. 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.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft