stylua
Opinionated Lua code formatter
TLDR
Format file
SYNOPSIS
stylua [--check] [--diff] [--config file] [options] [files]
DESCRIPTION
stylua formats Lua code according to configurable style rules. It enforces consistent formatting automatically.
Configuration in stylua.toml or .stylua.toml sets project preferences. Options include indentation, line width, quote style, and more.
Check mode verifies formatting without changes. It returns non-zero exit code if files would be reformatted, suitable for CI.
Diff mode shows what would change. This helps review formatting before applying it.
The formatter handles various Lua versions and can be configured for game-specific variants like Roblox Luau.
Integration with editors enables format-on-save. CI integration ensures consistent style across contributions.
PARAMETERS
--check
Check without formatting.--diff
Show diff without formatting.--config FILE
Configuration file.--search-parent-directories
Search for config in parents.--stdin-filepath PATH
Path for stdin input.--column-width N
Line width.--indent-type TYPE
Tabs or spaces.--indent-width N
Indent width.--line-endings TYPE
Unix or windows.--quote-style STYLE
String quote style.--call-parentheses STYLE
Call parentheses style.-g, --glob PATTERN
Glob pattern.-v, --verbose
Verbose output.
CONFIGURATION
stylua.toml or .stylua.toml
Project configuration file specifying formatting rules such as column width, indent type, quote style, and call parentheses behavior.
CAVEATS
Some style preferences can't be configured. Complex expressions may format unexpectedly. Very long lines may not wrap perfectly.
HISTORY
StyLua was created by JohnnyMorganz around 2020. Written in Rust, it provides fast, opinionated Lua formatting similar to Prettier for JavaScript.
