skillfed

luaparser

A lua parser in Python

luaparser v4.1.0 112.2K downloads/30d#12,378 on PyPI144
Permissive license MIT Active released

What it is and what it does

Luaparser is a Python library that reads Lua source code and builds an abstract syntax tree (AST), letting you programmatically inspect and manipulate Lua code structure. It ships both as a library for Python code and as a command-line tool. The parser supports Lua 5.3 and 5.4 grammar versions and can output AST data as JSON, XML, or pretty-printed text.

You can walk the entire AST to find specific node types, use a visitor pattern to process nodes, or construct AST objects directly in Python and regenerate Lua source code from them (though that feature is marked experimental). The library depends on antlr4-python3-runtime for parsing and multimethod for method dispatch.

Use it for:

  • Analyze Lua code structure in a static analysis or linting tool.
  • Extract function definitions, variable names, or call patterns from Lua scripts.
  • Transform or refactor Lua code by manipulating its AST and regenerating source.
  • Build development tools that need to understand Lua syntax without executing it.
  • Convert Lua code to other formats or intermediate representations via AST inspection.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Parses Lua source code into an abstract syntax tree (AST) and provides tools to traverse, analyze, and regenerate Lua code from the AST.

Yes. The package is actively maintained, has low install friction, carries a permissive MIT license, and solves a clear problem for anyone needing to parse or analyze Lua code in Python. No known vulnerabilities. The only caveat is that code regeneration is experimental, so rely on that feature cautiously.

Install

luaparser on PyPI

pip

pip install luaparser

uv

uv add luaparser

poetry

poetry add luaparser

Installing luaparser

Before you install

Low friction installation with a pure Python wheel and only two runtime dependencies (antlr4-python3-runtime and multimethod). Actively maintained with a recent release.

License in practice

MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects.

Quickstart

pip install luaparser

from luaparser import ast

src = "local x = 42"
tree = ast.parse(src)
print(ast.to_pretty_str(tree))

Verify before relying

  • Whether the parser handles all Lua 5.3 and 5.4 grammar features completely or if there are known gaps.
  • Performance characteristics when parsing large Lua files or complex nested structures.
  • Stability of the experimental Lua code regeneration feature (ast.to_lua_source).

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 2 — antlr4-python3-runtime, multimethod
Maintenance actively maintained — 25 days since the last release
Last repo commit
First released
Downloads 112,195/month — #12,378 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: luaparser-4.1.0-py3-none-any.whl

Intended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules

Tags

lua parser pythonlua ast builderparse lua codelua syntax analysislua code to astlua ast visitorlua grammar parser
parserastlua

More Python Modules packages