📱 Code Python on your phone with Python Coding - Learn PythonGet the free Android app →
  1. Home
  2. Python code visualizer

Free · runs in your browser · no sign-up

Python Code Visualizer

Run your program one line at a time and watch it work: the current line is highlighted, every variable and function call is shown, and the output builds up as you step forwards and backwards.

Code
Frames & variablesReady

Press Visualize to step through the program.

Output

    
Step 0 / 0

In shortPaste Python code, press Visualize, then use the slider or arrow keys to move through every step. At each step you see the line about to run, the variables in every active function (changes highlighted), the call stack, return values and the printed output — like Python Tutor, but running in your browser.

How to use it

  1. Write or paste code. Start with the sample (a function and a loop) or paste your own. Add any input() answers in the box below the code.
  2. Press Visualize. Python runs the program once and records every step (up to 1,000).
  3. Step through it. Use Next/Back, the slider, Play, or the ← → keys. The yellow line is the one about to run.
  4. Watch the variables. Each function call gets its own frame; values that just changed are highlighted.

Why visualize code?

Most beginner bugs come from a wrong mental picture of what the computer is doing: a loop that runs one time too few, a variable that's overwritten, a function that returns too early, a list that's shared by two names. Watching the program one line at a time replaces guessing with seeing. Teachers have used this "notional machine" approach for years — it's how Python Tutor became famous.

Reading the display

  • Highlighted line — the line Python is about to execute.
  • Global frame — variables created at the top level of your program.
  • Function frames — one per active call, newest at the bottom, so you can watch recursion build up and unwind. The frame shows return value when a function is about to return.
  • Yellow cells — values that changed since the previous step.
  • Output — everything printed up to this step.

Good programs to visualize

Run ▸def factorial(n):
    if n <= 1:
        return 1
    return n * factorial(n - 1)

print(factorial(4))

Step through it and watch four factorial frames stack up, then return 1, 2, 6 and 24 in turn. Other good ones: a bubble sort on a short list, a loop that builds a string, and two names pointing at the same list (a = [1]; b = a; b.append(2)).

Visualizer vs Python Tutor

Python Tutor draws arrows between objects and supports several languages; it sends code to a server and limits program size. This visualizer runs entirely in your browser, shows a type for every value and lets you jump straight to the compiler or syntax checker with the same code. Use whichever helps you see it.

Practise on your phone too

Python Coding - Learn Python for Android: a real Python 3 interpreter, code editor, 26 example programs and 12 marked exercises.

Get it on Google Play

Frequently asked questions

How do I see Python code run step by step?

Paste it into the visualizer on this page and press Visualize. Then press Next (or the → key) to execute one line at a time while watching variables and output.

Is this like Python Tutor?

Yes, it serves the same purpose — step-by-step execution with frames and variables — but it runs in your browser, so nothing is uploaded and there's no queue.

Does it work with recursion and functions?

Yes. Every active function call has its own frame, and return values are shown just before a function returns.

Can my program use input()?

Yes. Type the answers in the box under the code, one per line, before pressing Visualize.

Why does it stop after 1,000 steps?

To keep it fast and readable. If your program loops more than that, visualize a smaller version (fewer iterations) — the behaviour is the same.

Related

Updated 2026-10-22 · by the Coding Python team