Python Tutor
Visualize code execution. Step through Python, Java, JS, C, and C++ line by line.
Open the official app on pythontutor.com
This tool is hosted by its maintainers. Click below to open pythontutor.com in a new tab — it's their official demo.
Browse developer tools →What's next with Python Tutor?
Choose how you want to get started.
Use it free
Open the official tool or demo — no account needed.
Self-host it
Run the open-source version on your own infrastructure.
What is Python Tutor?
Python Tutor is an open-source web tool designed to visualize the execution of code step-by-step for programming languages like Python, Java, C, C++, and JavaScript. It addresses the challenge of understanding how programs operate by rendering variables, objects, pointers, data structures, and stack frames in real-time. This tool is widely used by students, educators, and developers to debug code, grasp complex programming concepts, and prepare for technical interviews. By providing a visual representation of program flow, Python Tutor bridges the gap between abstract code and tangible execution, making it easier to identify errors and learn fundamental computing principles. Its adoption spans over 180 countries, with institutions like MIT, Harvard, and UC Berkeley integrating it into their curriculum. The tool’s emphasis on interactive learning aligns with modern educational needs, offering a dynamic alternative to static code examples.
How it works
Python Tutor enables users to write and execute code in a web browser while observing its execution process through visualizations. It breaks down program behavior into discrete steps, highlighting how variables and data structures evolve over time. The tool’s primary purpose is to demystify programming by transforming abstract code into a series of visual events. This is particularly valuable for beginners struggling to connect syntax with program behavior, as well as for advanced users debugging complex logic. Python Tutor supports multiple languages, including Python, Java, C, C++, and JavaScript, making it versatile for both academic and professional settings. It visualizes stack frames, memory allocation, and recursive function calls, such as the listSum function’s execution at line 6. The AI Tutor feature allows users to request explanations or debugging assistance, enhancing its utility for self-paced learning.
How to use it
- 1Navigate to the Python Tutor website and select a supported language. 2. Enter code into the provided editor. 3. Click 'Visualize' to initiate step-by-step execution. 4. Use the controls to advance through each line of code, observing variable changes and memory states. Practical tips include leveraging the AI Tutor for unclear concepts and using the stack trace to track function calls.
What it can do
- Utility
Use cases
Assumptions and limitations
Assumptions
- source: https://github.com/python-tutor
- license: Open source
- privacy: Opens an external demo
Limitations
- GitHub repositories for the project occasionally encounter loading errors requiring page reloads
- Dependence on JavaScript may limit functionality in environments with disabled scripts
- The AI Tutor provides general guidance rather than real-time code analysis
- Visualization depth is limited to basic data structures and does not support advanced debugging features
- No offline functionality or local execution capabilities
Understanding the result
Visualize code execution. Step through Python, Java, JS, C, and C++ line by line.
Tool details
- Clearly flagged when a network request is needed.
- No account, no sign-up, and no tracking of your content.
- Powered by python-tutor (MIT).
- Built with
- python-tutor (https://github.com/python-tutor)
- License
- MIT
- Runs locally
- No — requires a network request
- Verification
- Not yet verified
- Input
- Code
- Output
- Output
Built with https://github.com/python-tutor. OpenToolVault provides the discovery and browser interface while crediting the original project maintainers.
- Built with
- python-tutor
- License
- MIT
Open-source project
OpenToolVault is an independent directory. We are not affiliated with or endorsed by this project.
References
- /python-tutor — GitHub Repository
Upstream project · GitHub
Frequently asked
What does Python Tutor visualize during code execution?
Python Tutor renders variables, objects, pointers, data structures, and stack frames in real-time. For example, it shows how a listSum function’s variables change as it processes each element, with stack traces indicating active function calls. This helps users track memory allocation and program flow.
How does Python Tutor handle multiple programming languages?
The tool supports Python, Java, C, C++, and JavaScript through separate visualization modules. Each language’s execution is parsed into discrete steps, with language-specific memory models (e.g., Java’s heap vs. Python’s dynamic scoping) accurately represented. Code syntax is validated before visualization to prevent errors.
How do I debug a recursive function like listSum using Python Tutor?
Enter the recursive function code into the editor, then click 'Visualize.' Use the step-through controls to observe how the function calls itself. The stack trace will show nested calls, and variable states will update as each recursion level completes. The AI Tutor can explain how base cases terminate the recursion.
How does Python Tutor compare to alternatives like JDoodle or Replit?
Unlike JDoodle or Replit, which focus on code execution and sharing, Python Tutor emphasizes visualization of program state. It provides detailed memory and stack frame diagrams, making it better for learning concepts like pointers and recursion. Replit offers integrated development environments (IDEs), while Python Tutor is specialized for educational visualization.
What should I do if the visualization fails to load?
Refresh the page, as GitHub repository loading errors often resolve with a reload. Ensure JavaScript is enabled in your browser, as the tool relies on client-side scripting. If the issue persists, check for network connectivity problems or try a different browser. For persistent errors, consult the project’s GitHub issues page.