skillfed

ast-decompiler

Python module to decompile AST to Python code

ast-decompiler v0.8.0 176.0K downloads/30d#10,256 on PyPI40
Permissive license Active released

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-decompiler

uv

uv add ast-decompiler

poetry

poetry add ast-decompiler

Installing 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

Environment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: Python Software Foundation LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development

Tags

ast to code generationdecompile python astreconstruct source from astast code generationpython ast decompilergenerate code from astast to source code
ast-manipulationcode-generation

More Software Development packages