astpretty
Pretty print the output of python stdlib `ast.parse`.
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction: pure Python wheel with no runtime dependencies.
- Actively maintained as of 2026-07-15 with 200 repository stars.
License · maintenance · safety
MIT (permissive) — MIT license (permissive) places no restrictions on use, modification, or distribution.
last release 2022-05-16 (1551 days) · last repo commit 2026-07-15 · 200 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 552,844 downloads/mo, #6,041 on PyPI
Alternatives
Verify before relying
pip install astpretty
import ast
import astpretty
node = ast.parse('if x == y: y += 4').body[0]
astpretty.pprint(node)- 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.
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 on this page. Verify before relying on it.
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
astpretty on PyPI
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 the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 1,551 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 552,844 / month, #6,041 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy |
Evidence: astpretty-3.0.0-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “ast pretty print”
- astprettyPretty-print Python abstract syntax trees (AST) from stdlib ast.parse…
- astunparseConverts Python abstract syntax trees (ASTs) back into source code…
- icecreamIceCream provides a drop-in replacement for print() debugging that…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also gast · objprint · astunparse · ast-decompiler · typed-ast · google-pasta · ast-comments · stdlibs · astor · luaparser