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.
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.
The code is broken down into atomic tokens: keywords (def, if), identifiers (price), literals (0.10), and operators (*, <=).
Tree-sitter evaluates grammar rules and arranges tokens into hierarchical syntax nodes like function_definition, if_statement, and return_statement.
By traversing this tree, linters (Flake8, Ruff), AI coding assistants, and visualizers like Creview calculate cyclomatic complexity and token footprints without executing code.
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 |
Key node classifications you will encounter when analyzing Python source code:
FunctionDef / async_defDefines a callable function or coroutine. Contains arguments, return annotations, decorators, and a body statement block.
IfStatement & ElifControl flow branch. Each decision branch increases cyclomatic complexity by +1, creating split execution paths.
Call & AttributeInvokes a function or method on an object (e.g., items.append(x)). Used by Creview to trace module dependencies.
TryStatement & ExceptClauseHandles runtime exceptions. Creview highlights these to show error recovery paths across services.
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.
Never. Snippet analysis is executed purely in-memory and immediately discarded. No source code is written to disk or used for machine learning datasets.
Yes. The full Creview application supports uploading multi-file ZIP archives and public GitHub repository URLs to generate comprehensive cross-file dependency maps.