Node.js Event Loop Visualizer

A 7-lesson learning path with step-by-step animation. See the call stack, nextTick queue, microtasks and libuv phases move in real time, and predict the console output before you press play.

Lesson 1 of 7 · Beginner

The call stack

Understand how synchronous code runs, one frame at a time.

Code
1function third() { console.log('third') }
2function second() { third() }
3function first() { second() }
4console.log('start')
5first()
6console.log('end')

Predict the output

What will the console print, in order?

Call stack

runs JS
  • main()

nextTick queue

1st priority
  • empty

Microtasks

promises
  • empty

Event loop (libuv)

t = 0ms

Timers

setTimeout
  • empty

Poll (I/O)

fs, net
  • empty

Check

setImmediate
  • empty

Pending, idle/prepare and close phases are internal and not animated.

Console
nothing printed yet
The script starts. main() is pushed onto the call stack.
1/12

JavaScript runs on a single thread with a single call stack. Calling a function pushes a frame, returning pops it, and the last function called is the first to finish (LIFO). Nothing else can run until the stack is empty.

How to Use

01

Pick a lesson from the learning path. They go from the call stack to a final mixed-queue challenge.

02

Read the code, then predict the console output by choosing one of the options.

03

Press Play, or step forward one frame at a time, and watch items move between queues.

04

Read the narration under the stage. It explains every move the event loop makes.

05

Finish all seven lessons, then test yourself with the Node.js Fundamentals interview drill.

What Is This Tool?

The Node.js event loop is the scheduler behind every callback, promise and timer in your server. This visualizer turns it into a guided learning path: seven short lessons, each with real code, an animated call stack, nextTick and microtask queues, and the libuv phases (timers, poll, check), so you can see why the console prints in the order it does.

Why It Matters

Event loop ordering is one of the most common Node.js interview topics and the root cause of many production bugs: starved timers, surprising log order and blocked requests. Understanding it makes async code predictable.

The four things to remember

1) Synchronous code always finishes first. 2) process.nextTick runs before promises. 3) Microtasks drain completely between every callback. 4) The loop visits timers, then poll, then check, in that order.

Who is this for?

Developers learning Node.js, frontend engineers moving to the backend, and anyone preparing for a technical interview. No setup is needed: everything runs in your browser.

Developer Tip
Predict first, watch second. Guessing the output before you press play builds the mental model far faster than just watching.

Frequently Asked Questions