ast-decompiler
Python module to decompile AST to Python code
What it is and what it does
ast_decompiler takes a Python AST object and generates human-readable Python source code from it. This is useful when you have parsed code as an AST (via ast.parse or similar) and need to recover or inspect the original source, or when you're working with dynamically constructed ASTs and want to see what code they represent.
The package supports Python 3.8 through 3.13 and has no runtime dependencies, making it lightweight to integrate. It is actively maintained with recent activity, and the codebase is formatted with Black. The module is straightforward to use: pass an AST node to the decompile function and receive a string of reconstructed Python code.
Use it for:
- Debug or inspect dynamically generated or modified ASTs by converting them back to readable code.
- Implement code transformation tools that need to display or log the result of AST modifications.
- Build educational tools or documentation that show how Python code maps to its AST representation.
- Generate test fixtures or example code from programmatically constructed AST objects.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts Python abstract syntax trees (ASTs) back into readable Python source code, allowing you to reconstruct or inspect code from its parsed AST representation.
Yes. The package is lightweight (no dependencies), actively maintained with recent commits, supports current Python versions, and has no known vulnerabilities. Install it if you need to convert ASTs back to source code for inspection, debugging, or code generation workflows.
Install
ast-decompiler on PyPI
pip
pip install ast-decompileruv
uv add ast-decompilerpoetry
poetry add ast-decompilerInstalling ast-decompiler
Before you install
Low friction install with no runtime dependencies. The package is actively maintained with recent commits and supports current Python versions (3.8–3.13), making it reliable for modern projects.
License in practice
Licensed under the Python Software Foundation License, a permissive license that allows broad use with minimal restrictions.
Quickstart
import ast
from ast_decompiler import decompile
code = decompile(ast.parse('(a + b) * c'))
print(code) # Output: (a + b) * c
Verify before relying
- Completeness of AST-to-code coverage: whether all Python constructs are supported or if some edge cases remain unhandled.
- Performance characteristics on large or deeply nested ASTs.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 819 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 175,951/month — #10,256 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ast_decompiler-0.8.0-py3-none-any.whl
Keywords: ast, decompiler
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
astroidAstroid builds an extended abstract syntax tree…
copyleft · top 1,000 on PyPI
asttokensAnnotates Python abstract syntax trees with the…
permissive · top 1,000 on PyPI
astunparseConverts Python abstract syntax trees (ASTs)…
permissive · top 5,000 on PyPI
google-pastaParse Python source code into an AST, modify…
permissive · top 1,000 on PyPI
astorastor converts Python abstract syntax trees…
permissive · top 5,000 on PyPI
benigetBeniget performs compile-time analysis on…
permissive · top 15,000 on PyPI
astprettyPretty-print Python abstract syntax trees (AST)…
permissive · top 15,000 on PyPI
ast-commentsExtends Python's built-in `ast` module to…
permissive · top 15,000 on PyPI
luaparserParses Lua source code into an abstract syntax…
permissive · top 15,000 on PyPI
decompyle3Decompyle3 translates Python bytecode back into…
copyleft · top 15,000 on PyPI