Node.js Event Loop Simulator

Paste a script using setTimeout, setImmediate, process.nextTick, Promise, and readFile (simulated), then step through the event loop phases to see exactly what runs when.

Script Editor
Choose an example or paste your own Node-like code (subset supported).
IDLE
Notes:
  • Supported APIs: console.log, setTimeout, setImmediate, process.nextTick, Promise, readFile.
  • readFile is simulated and completes in a future poll phase.
  • async/await is not guaranteed; prefer Promise.then for accuracy in this simulator.
Event Loop Visualizer
Next TickMicrotasksTimersI/O (Poll)Check
Next Tick Queue0
Empty

Tiny to-dos that run right after the current task, before anything else.

Microtask Queue (Promise)0
Empty

Promise helpers (.then/.catch/.finally) run right after nextTicks.

Timers (setTimeout)0
Empty

Things scheduled to happen later. When time is up, they run here.

I/O (poll)0
Empty

Waiting for files or network. When the data is ready, the callback runs here.

Check (setImmediate)0
Empty

Runs at the very end of a tick, after I/O is processed.

Timeline
No steps yet. Load your script, then Step or Run.
How it works
This simulator models Node’s event loop phases and queues. Your code is executed in a sandbox that schedules callbacks into queues instead of running them immediately. Stepping runs one callback at a time and flushes microtasks (nextTick, Promise).
The event loop iterates through phases in order:
  1. timers (setTimeout/setInterval callbacks whose time has elapsed)
  2. pending callbacks (system operations) — omitted here for simplicity
  3. idle, prepare — internal, omitted
  4. poll (retrieves and executes I/O callbacks)
  5. check (setImmediate callbacks)
  6. close callbacks — omitted
Built with v0