Online Developer Tool • Free

Interactive Python AST Visualizer

Parse and inspect Python Abstract Syntax Trees in real time. Examine hierarchy nodes, function definitions, control flow decisions, and cyclomatic complexity without installing local compilers.

Python Source Code
Parsed Syntax Tree Ready
Click "Analyze AST" to parse the syntax tree.
Tree Tokens: -
AST Nodes: -
Language: Python 3

What is a Python Abstract Syntax Tree (AST)?

An Abstract Syntax Tree (AST) is a structural, tree-shaped representation of the source code produced during compiler/interpreter analysis. Unlike concrete syntax trees, an AST omits trivial details such as semicolons, commas, and parentheses, exposing the structural logic of variables, expressions, and execution branches.

1. Lexical Tokenization

The code is broken down into atomic tokens: keywords (def, if), identifiers (price), literals (0.10), and operators (*, <=).

2. Grammatical Parsing

Tree-sitter evaluates grammar rules and arranges tokens into hierarchical syntax nodes like function_definition, if_statement, and return_statement.

3. Analysis & Refactoring

By traversing this tree, linters (Flake8, Ruff), AI coding assistants, and visualizers like Creview calculate cyclomatic complexity and token footprints without executing code.

How Creview Compares with Other Python AST Tools

Developers frequently need to choose between command-line outputs, generic web tools, and full architectural visualizers.

Tool Interactive Visual Graph Token Count & LLM Footprint Multi-File / GitHub Support Setup Requirement
Creview Visualizer Yes (Interactive zoom & pan) Yes (Tree & BPE tokens) Yes (ZIP upload & GitHub URL) None (Online in browser)
Python `ast.dump()` No (Terminal text dump) No No (Single file script) Python environment required
AST Explorer JSON tree view only No No (Single snippet only) None
Sourcetrail Yes (Desktop graph) No Yes (Local indexing) Heavy desktop install

Common Python AST Node Types

Key node classifications you will encounter when analyzing Python source code:

FunctionDef / async_def

Defines a callable function or coroutine. Contains arguments, return annotations, decorators, and a body statement block.

IfStatement & Elif

Control flow branch. Each decision branch increases cyclomatic complexity by +1, creating split execution paths.

Call & Attribute

Invokes a function or method on an object (e.g., items.append(x)). Used by Creview to trace module dependencies.

TryStatement & ExceptClause

Handles runtime exceptions. Creview highlights these to show error recovery paths across services.

Frequently Asked Questions

How do I visualize a Python Abstract Syntax Tree online?

Paste any valid Python snippet in the editor above and click "Analyze AST". The visualizer will construct the parsed node tree, showing hierarchical relationships and execution order.

Does Creview store or train AI models on my code?

Never. Snippet analysis is executed purely in-memory and immediately discarded. No source code is written to disk or used for machine learning datasets.

Can I visualize an entire Python package or GitHub repository?

Yes. The full Creview application supports uploading multi-file ZIP archives and public GitHub repository URLs to generate comprehensive cross-file dependency maps.

Analyze Entire Repositories with Creview

Ready to map full multi-file architectures, detect circular dependencies, and calculate token footprints for your whole team?

Open Full Creview Visualizer