File structure
The diagram file is a JSON file with several sections. The basic file structure is as follows:"version" is always 1, "author" is the name of the person who created the file, and "editor" is the name of the application that was used to edit the file (“wokwi”).
In addition, you can add a "serialMonitor" section to configure the Serial Monitor.
Parts
The"parts" section defines the list of components in the simulation. It’s an array of objects with the following properties:
| Name | Type | Description |
|---|---|---|
| id | string | the unique identifier of the part (e.g. “led1”) |
| type | string | the type of the part (e.g. “wokwi-led”) |
| left | number | x screen coordinate (in pixels) |
| top | number | y screen coordinate (in pixels) |
| attrs | object | part attributes (e.g. “color” for wokwi-led) |
| rotate | number | rotation in degress (e.g. 90) |
| hide | boolean | if true, the part won’t be visible |
id and type are required, the other fields are optional.
For example, here’s how you define a red LED called "led1" at position (x=100, y=50):
Use
wokwi-cli lint to validate your diagram.json file and catch common issues like unknown part types, invalid pin connections, and duplicate IDs. See the CLI Usage guide for more details.wokwi-attiny85- ATtiny85wokwi-arduino-nano- Arduino Nanowokwi-arduino-mega- Arduino Mega 2560wokwi-arduino-uno- Arduino Uno R3wokwi-pi-pico- Raspberry Pi Picoboard-esp32-devkit-c-v4- ESP32 (official devkit)wokwi-esp32-devkit-v1- ESP32 (unofficial devkit)board-esp32-c3-devkitm-1- ESP32-C3board-esp32-c3-rust-1- ESP32-C3board-esp32-c6-devkitc-1- ESP32-C6board-esp32-h2-devkitm-1- ESP32-H2board-esp32-s2-devkitm-1- ESP32-S2board-franzininho-wifi- ESP32-S2board-esp32-s3-devkitc-1- ESP32-S3board-esp32-p4-preview- ESP32-P4board-st-nucleo-c031c6- STM32 Nucleo-64 with STM32C031C6 MCUboard-st-nucleo-l031k6- STM32 Nucleo-32 with STM32L031K6 MCUboard-xiao-esp32-c3- ESP32-C3board-xiao-esp32-c6- ESP32-C6board-xiao-esp32-s3- ESP32-S3
Instead of manually specifying the left/top coordinates for each item, you can drag them with the mouse to the desired position.
Connections
The"connections" section defines how the parts are connected. Each connection is an array with four items:
- The source component id and pin name, separated by a colon. e.g.
partId:pinName - The target component id and pin name
- The color of the wire (or an empty string to hide the wire)
- A list of instructions how to place the wire, as an array of strings (optional)
led1 to pin 13 of the uno part:
Wire placement mini-language
Each item in the"connections" section can specify a list of instructions how to draw the lines for the wire. Wires always go in straight lines, either horizontally or vertically, and never diagonally.
There are three instructions:
- “v” followed by a number of pixels: move vertically (up/down)
- “h” followed by a number of pixels: move horizontally (left/right)
- ”*” can appear only once. All the instructions that appear before the ”*” apply to the source pin, and the instructions that appear after it apply to the target pins.
Wire placement animation
If you are a visual learner, you may find the following GIF animation useful. The animation was created by Steve Sigma.