Press Visualize to run
The program runs once, then plays back here step by step: a card for every frame with its variables, an arrow for each call and return, and the two lines in the editor (just ran, up next).
Click a line number to add one. Visualize then opens paused at the first breakpoint hit.
The Python Code Visualizer runs your program once on a real CPython 3.14.10 runtime and records every step it takes: each line, each function call and each return. You then play that recording forwards and backwards: the editor marks the line that just ran and the line up next, the canvas draws a card for every frame on the call stack with its variables and an arrow for each call and return value, and the output panel shows exactly what the program had printed at that point. It is the quickest way to see what a loop, a recursive call or an exception actually does.
The recording comes from the same engine as the Debug feature of the Python compiler, so breakpoints, conditions and step over / into / out all work here too. Nothing runs in your browser and nothing runs while you type: one Visualize click is one run. If you were looking for charts and plots rather than code execution, the Matplotlib compiler is the tool for that.
Type or paste one Python file, or pick a program from Examples. The Input box under the editor feeds input(), one line per call.
One click runs the program once on a hosted CPython runtime under a recorder. Nothing runs while you type.
Next and Back move one executed line at a time; Play runs forward at the speed you choose; the slider jumps anywhere. Step over, Step out and F8 (next breakpoint) work as in a debugger.
The current line is highlighted in the editor, the Frames panel shows every active call with its variables, and Output shows what had been printed at that step.
Click a line number to set one. Visualize opens at the first breakpoint hit; conditions and hit counts are behind the pencil.
The editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.
Type or paste a Python program (or pick one from Examples), then press Visualize or Ctrl/Cmd + Enter.
The program runs once on a hosted CPython runtime under a recorder. When the run finishes the visualizer opens at the first executed line.
Nothing runs while you type and nothing runs in your browser.
Playback starts by itself after Visualize. Next (→) and Back (←) move one step at a time: a line, a call or a return. Play runs forward at ½×, 1×, 2× or 4× steps per second; Space pauses.
The slider jumps anywhere in the run. Home and End go to the first and last step.
Step over (F10) skips a function call, Step out (Shift+F11) finishes the current function, and F8 runs to the next breakpoint.
The Frames canvas shows the global frame on the left and one card per active function call on the right, oldest at the top, the paused frame last and highlighted. Each card is titled with the call as it was made, factorial(3), and an arrow leads from every caller to the frame it opened: "calls factorial(3)" on the way in, "returns 6" on the way back.
Each card shows the frame’s local variables with their values at that step; the ones that changed on this step are tinted. Lists, tuples, dicts, sets and objects expand to three levels; long containers are cut at 12 items.
Click a frame card to highlight its line in the editor.
The visualizer shows the frames, not the program’s printed output: it is about how the program runs. To see what it prints, run the same program in the Python compiler (the language switcher in the header gets you there).
An uncaught exception stops the recording at the raising line, marked red in the editor, with the error named in the Frames pane and the status bar.
The last step shows "All n steps executed" with the exit status; a run that was stopped by a limit says so in the status pill.
Click a line number (or press F9) to toggle a breakpoint. Visualize opens at the first breakpoint hit; F8 runs to the next one. The pencil in the Breakpoints list adds a condition or a hit count.
Program input goes in the Input tab next to Frames, one line per input() call. Examples that read input() open it for you.
A recording covers the first 2,000 executed lines or 5 seconds; the program runs on.
Share in the header makes a link to the program and its input; the link opens this visualizer, lasts 30 days, and whoever opens it works on their own copy.
Recursion: factorial: Watch a frame open for every call and the results come back as the stack unwinds.
For loop with a running total: Step through each iteration and see total and item change line by line.
Functions, arguments and return values: Local variables live in their own frame; the return value lands in the caller.
Two names, one list: Assignment does not copy: a change through one name shows up in the other.
Counting words with a dictionary: See the dictionary grow one key at a time as the loop runs.
Raising and catching an exception: Follow the jump from the raising line into the except block and on to finally.
A class with a method: __init__ runs with self; each method call gets its own frame.
While loop: Fibonacci numbers: Tuple assignment swaps a and b each time round the loop.
Building a string: Slicing and concatenation, one character at a time.
Reading input(): Lines from the Input box are read one at a time; the values appear in the frame.
Sum of natural numbers: A while loop counting up; watch total and n change on every pass.
Palindrome check: Compare a word with its reverse inside a function that returns True or False.
Prime number check: Trial division in a loop with an early return; see which divisor ends it.
Reverse a string: Build the reversed text one character at a time in a for loop.
Find the largest and smallest: Two running values updated by if statements as the loop walks the list.
Swap two variables: A temporary variable swap, then the one-line Python way; watch the values trade places.
Count the vowels: A membership test on each character; the counter grows only on vowels.
Even or odd: The modulo operator decides which branch runs for each number.
Multiplication table: A for loop over range(); the product changes on every row.