--- id: astpretty version: "3.0.0" license: MIT license_treatment: permissive maintenance: active --- # astpretty — Pretty print the output of python stdlib `ast.parse`. License: permissive · Maintenance: active · Downloads: 552.8K/mo ## What it is and what it does astpretty formats Python abstract syntax trees into indented, readable output that makes it easy to inspect the structure of parsed code. It wraps stdlib ast.parse results and provides two main functions: pprint() to display a tree directly, and pformat() to return it as a string. You can control indentation style and choose whether to include line/column offset metadata, which ast.dump does not easily allow. The package is a thin, zero-dependency utility designed for developers debugging or analyzing Python code at the AST level—particularly useful in linters, code generators, and syntax analysis tools. It also supports typed-ast for type-annotated parsing when installed as an optional extra. Use it for: - Debug Python code by inspecting its AST structure during linter or code-analysis tool development. - Visualize parsed syntax in REPL sessions or notebooks to understand how Python parses specific code patterns. - Generate readable AST dumps in test output or documentation to verify code transformation logic. - Inspect type-annotated code structures when using typed-ast for Python 2 or type-comment parsing. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Pretty-print Python abstract syntax trees (AST) from stdlib ast.parse in a readable, hierarchical format with optional line/column offsets, as a more legible alternative to ast.dump. Yes. astpretty is a lightweight, actively maintained utility with no dependencies, permissive licensing, and a clear single purpose: making AST inspection readable. Install it if you work with Python's ast module and want output that doesn't collapse into a single unreadable line. No security concerns, no friction. ## Install pip install astpretty uv add astpretty poetry add astpretty ## Installing astpretty Before you install: Low friction: pure Python wheel with no runtime dependencies. Actively maintained as of 2026-07-15 with 200 repository stars. License in practice: MIT license (permissive) places no restrictions on use, modification, or distribution. Quickstart: pip install astpretty import ast import astpretty node = ast.parse('if x == y: y += 4').body[0] astpretty.pprint(node) Verify before relying: - Whether typed-ast support (optional via extras) remains actively maintained or tested. - Current test coverage and whether the package handles edge cases in modern Python AST structures. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 552.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags ast pretty print, python ast visualization, ast.dump alternative, readable ast output, ast formatting tool, debug python syntax trees, ast-inspection, debugging-tool, code-analysis [View on SkillFed](https://skillfed.io/packages/astpretty) · [View on PyPI](https://pypi.org/project/astpretty/)