A deterministic code formatter for Lua 5.1-5.4, LuaJIT, Luau, and CfxLua, inspired by Prettier.
StyLua is a deterministic code formatter for Lua and its variants (Lua 5.1-5.4, LuaJIT, Luau, CfxLua). It automatically rewrites code to enforce a consistent style, eliminating formatting inconsistencies and improving readability across teams. Inspired by Prettier, it parses and reprints code from scratch.
Lua developers working across different Lua versions (including Roblox Luau and FiveM CfxLua) who want automated, consistent code formatting in their projects.
Developers choose StyLua for its robust support of multiple Lua dialects, deterministic output, and seamless integration with editors and CI/CD pipelines. Its opinionated defaults reduce configuration overhead while remaining customizable.
A Lua code formatter
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports Lua 5.1 through 5.4, LuaJIT, Luau, and CfxLua, making it versatile for diverse Lua environments like Roblox and FiveM.
Guarantees the same formatting every time by parsing and reprinting code from scratch, eliminating style debates and improving readability.
Integrates with VS Code, Neovim, Sublime, and as an LSP server, plus offers pre-commit hooks and GitHub Actions for automated pipelines.
Provides key options like line width and indentation, with sensible defaults based on the Roblox Lua Style Guide, reducing setup overhead.
The default build includes all Lua variants, which can cause conflicts (e.g., Lua 5.2 goto vs. Luau type assertions), requiring explicit syntax setting in .stylua.toml.
Only offers a handful of configuration settings, which may not cover all stylistic preferences or complex formatting needs, as noted in the limited options table.
Requires installing a pre-built binary or building from source with Rust, and managing syntax features can add setup steps for specific environments.
The --verify flag for checking formatting correctness is acknowledged to produce false positives and negatives, necessitating manual checks in large codebases.