astunparse
An AST unparser for Python
Decision gist · record as of 2026-08-14
Yes, if you work with Python versions supported at the last release (2019-12-22) and need reliable AST-to-source conversion. The code is stable and well-tested. No if you require support for newer Python versions—the abandoned status means no updates are coming. Consider alternatives if you need active maintenance.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Abandoned since 2019-12-22; no updates for Python versions beyond those listed in classifiers.
- May not handle newer syntax features.
- Low friction install with minimal dependencies (wheel, six).
License · maintenance · safety
BSD (permissive) — BSD license is permissive; you can use, modify, and distribute this code with minimal restrictions, though you must retain the license notice.
last release 2019-12-22 (2427 days) · last repo commit 2023-08-18 · 230 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 14,034,836 downloads/mo, #1,251 on PyPI
Alternatives
Verify before relying
import ast
import astunparse
code = "x = 1 + 2"
tree = ast.parse(code)
print(astunparse.unparse(tree))
print(astunparse.dump(tree))- Compatibility with Python versions released after 2019-12-22 and AST node types introduced after that date.
- Whether roundtrip fidelity is maintained for Python constructs added after the last release.
What it is and what it does
astunparse is a library that converts Python AST (abstract syntax tree) objects back into readable source code and provides a pretty-printed dump of AST structure. It factors out the unparse utility from Python's standard library, making it available as a standalone package.
The library is built on mature, core-maintained code from the Python source distribution and roundtrips much of the standard library. It depends only on wheel and six, making installation straightforward. However, the project is abandoned—last updated 2019-12-22—so it will not receive updates for newer Python versions or syntax features.
Use it for
- Recover source code from compiled or introspected AST objects for debugging or code analysis.
- Generate readable Python code from programmatically constructed AST trees in code generation tools.
- Pretty-print AST structure for educational purposes or to understand how Python parses code.
- Roundtrip Python source through parse and unparse cycles to verify AST fidelity in testing.
- Implement metaprogramming tools that need to display or manipulate AST as human-readable code.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you work with Python versions supported at the last release (2019-12-22) and need reliable AST-to-source conversion.
The code is stable and well-tested. No if you require support for newer Python versions—the abandoned status means no updates are coming. Consider alternatives if you need active maintenance.
Install
astunparse on PyPI
Before you install
Low friction install with minimal dependencies (wheel, six). Maintenance is abandoned—last release was 2019-12-22 and last commit 2023-08-18—so expect no active bug fixes or support for newer Python versions.
Abandoned since 2019-12-22; no updates for Python versions beyond those listed in classifiers. May not handle newer syntax features.
License in practice
BSD license is permissive; you can use, modify, and distribute this code with minimal restrictions, though you must retain the license notice.
Quickstart
import ast
import astunparse
code = "x = 1 + 2"
tree = ast.parse(code)
print(astunparse.unparse(tree))
print(astunparse.dump(tree))
Verify before relying
- Compatibility with Python versions released after 2019-12-22 and AST node types introduced after that date.
- Whether roundtrip fidelity is maintained for Python constructs added after the last release.
Package facts
| License | BSD permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packageswheelsix |
| Maintenance | Abandoned 2,427 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 14,034,836 / month, #1,251 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Topic :: Software Development :: Code Generators |
Evidence: astunparse-1.6.3-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 › “unparse python ast”
- astunparseConverts Python abstract syntax trees (ASTs) back into source code…
- ast-commentsExtends Python's built-in `ast` module to preserve comments as nodes…
- reqifReqIF is a Python library for parsing, unparsing, formatting,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Code Generators packages
Proto Plus wraps protocol buffers to provide Python classes that behave like native Python types while maintaining protocol buffer serialization and schema validation.
Install it if you're working with protocol buffers in Python and want a more Pythonic interface, or if you're using Google Cloud libraries that depend on it.
Cython is a source code translator that compiles Python code to C, enabling optional static typing and direct C/C++ interoperability to generate efficient native extensions.
Install it if you need to optimize Python performance, wrap C/C++ libraries, or build fast native extensions.
Annotates Python abstract syntax trees with the positions of tokens and source code text, enabling tools to map AST nodes back to their originating code for refactoring, analysis, and transformation.
Beartype is a runtime type checker that validates Python type hints at function call time, catching type violations before they cause downstream bugs.
Install it if you want runtime type safety for your annotated code or need to validate type hints on third-party packages.
llvmlite provides a lightweight Python binding to LLVM's IR builder, optimizer, and JIT compiler APIs, enabling you to write JIT compilers and code generators without needing the full LLVM C++ API surface.
astor converts Python abstract syntax trees (ASTs) back to readable source code and provides tools for AST manipulation, inspection, and non-recursive tree traversal.
Install it if you need AST round-tripping or advanced tree inspection.
See also ast-decompiler · ast-comments · astpretty · google-pasta · luaparser · gast · libcst · beniget