LinthelmIntroductions to linters, static analysis and code-quality tools

Formatters · 5 tools

Top 5 code formatter tools for Lua game scripts and Neovim configs

By the Linthelm editorial team · Published · Updated · Facts checked 21 November 2026 (Asia/Dhaka)

For consistent Lua formatting, start with StyLua, which is built for Lua and its variants, then look at dprint and Prettier for the other files in the same repository. This shortlist is for Lua and Neovim plugin developers who also keep JSON, Markdown, TOML, shell or C-family files next to their scripts. The last two entries, shfmt and clang-format, cover neighbouring languages rather than Lua itself.

At a glance: the shortlist in order of fit for this use case
#ToolBest forKey featurePlatforms / deploymentPricingMore
1StyLuaJohnnyMorganzLua, Luau and FiveM script codebases, including Neovim pluginsSupports Lua 5.1-5.4, LuaJIT, Luau and CfxLua/FiveM LuaPre-built binaries on GitHub Releases, cargo, Homebrew on macOS, Docker Hub, a WASM library for Node.js or the browser, a GitHub Action and three pre-commit hooksSee vendor pricing pageIntroduction
2dprintdprintRepositories mixing Lua with JSON, Markdown, TOML and similar filesOfficial plugins cover TypeScript/JavaScript, JSON, Markdown, TOML, Dockerfile, SQL and Jupyter notebooksSingle static binary with no runtime dependencies; installable via shell script, PowerShell, npm, Homebrew or CargoSee vendor pricing pageIntroduction
3PrettierPrettierTeams that want style debates removed from code reviewIntegrates with most editors and can format on saveNot stated on official pagesSee vendor pricing pageIntroduction
4shfmtmvdanShell scripts in a Lua or game projectFormats shell programs with a documented default stylePackages available across many operating systems and package managers; Docker images; written in pure GoSee vendor pricing pageIntroduction
5clang-formatLLVM ProjectC, C++ and C# engine or binding code beside Lua scriptsPreset styles, with configuration loaded from a .clang-format file in parent directoriesNot stated on official pagesSee vendor pricing pageIntroduction

1 StyLua

By JohnnyMorganz

StyLua is a deterministic code formatter for Lua 5.1-5.4, LuaJIT, Luau and CfxLua/FiveM Lua, built using full-moon. It parses the codebase and reprints it from scratch to enforce a consistent style, similar to prettier.

Why it is here: It is the only tool in this list documented specifically for Lua and its game-scripting variants, so it fits this use case most directly.

Best for
Lua, Luau and FiveM script codebases, including Neovim plugins
Key features
  • Supports Lua 5.1-5.4, LuaJIT, Luau and CfxLua/FiveM Lua
  • Mainly follows the Roblox Lua Style Guide
  • --check reports files needing formatting, with machine-readable JSON output among the formats
  • --verify re-parses formatted output to confirm it is still valid
  • Comment directive to skip formatting for part of a file, and range formatting
Limits
Documented for Lua and its variants only, so JSON, Markdown or shell files in the same repository need another formatter. Editor integrations for Sublime, Neovim and Zed require the StyLua binary to be installed. Cargo builds for Lua 5.1 by default, with feature flags for other syntaxes.
Platforms / deployment
Pre-built binaries on GitHub Releases, cargo, Homebrew on macOS, Docker Hub, a WASM library for Node.js or the browser, a GitHub Action and three pre-commit hooks
Pricing
See vendor pricing page (not quoted here; facts checked 21 November 2026, Asia/Dhaka)

2 dprint

By dprint

dprint is a pluggable, configurable code formatting platform written in Rust that formats many languages through one CLI. It aims to be a single formatting tool for every language in a repository.

Why it is here: It sits next because one dprint.json can cover the non-Lua files around a Lua project, and its Exec plugin can wrap any other CLI formatter.

Best for
Repositories mixing Lua with JSON, Markdown, TOML and similar files
Key features
  • Official plugins cover TypeScript/JavaScript, JSON, Markdown, TOML, Dockerfile, SQL and Jupyter notebooks
  • Exec plugin can wrap any other CLI formatter
  • Wrapper plugins integrate Prettier, Biome and Oxc
  • Wasm plugins run sandboxed, with incremental caching by default
  • dprint init scaffolds a dprint.json; dprint check verifies code is already formatted
Limits
A Lua plugin is not listed among the official plugins on the vendor page. Teams that want Lua formatted through dprint should check the vendor documentation for plugin options or use the Exec plugin with a separate Lua formatter.
Platforms / deployment
Single static binary with no runtime dependencies; installable via shell script, PowerShell, npm, Homebrew or Cargo
Pricing
See vendor pricing page (not quoted here; facts checked 21 November 2026, Asia/Dhaka)

3 Prettier

By Prettier

Prettier is an opinionated code formatter that integrates with most editors and automatically enforces a consistent code style. It acts as a fully automatic style guide meant to end ongoing debates over code style.

Why it is here: It is a widely integrated formatter for the web and config files in a Lua project, so it comes after the tools that handle Lua or span several languages through one config.

Best for
Teams that want style debates removed from code review
Key features
  • Integrates with most editors and can format on save
  • Can run as part of pre-commit scripts or githooks
  • Can clean up an existing inconsistent codebase quickly
  • Aims to use the least controversial coding styles
  • Built-in support for Lightning Web Components (LWC)
Limits
The vendor page does not list Lua support, and its stated audience centres on JavaScript developers and development teams. Check the vendor documentation before relying on it for Lua files.
Platforms / deployment
Not stated on official pages
Pricing
See vendor pricing page (not quoted here; facts checked 21 November 2026, Asia/Dhaka)

4 shfmt

By mvdan

shfmt is a shell script formatter from the mvdan/sh project, which also provides a shell parser and interpreter supporting POSIX Shell, Bash, Zsh and mksh. It has a documented default style.

Why it is here: It suits the build, install and CI shell scripts that often sit beside game scripts and editor configs, but it does not format Lua.

Best for
Shell scripts in a Lua or game project
Key features
  • Formats shell programs with a documented default style
  • Deliberately limits formatting options to prioritize consistency for teams
  • Converts shell to and from a JSON syntax tree
  • Release tags published as Docker images
  • sh-checker GitHub Action performs static analysis for shell scripts using shfmt
Limits
Documented for shell scripts only, so it complements a Lua formatter rather than replacing one. Formatting cannot be disabled for ranges of lines.
Platforms / deployment
Packages available across many operating systems and package managers; Docker images; written in pure Go
Pricing
See vendor pricing page (not quoted here; facts checked 21 November 2026, Asia/Dhaka)

5 clang-format

By LLVM Project

ClangFormat is a set of tools built on LibFormat that formats C, C++, Java, JavaScript, JSON, Objective-C, Protobuf and C# code. It works as a standalone tool and through editor integrations.

Why it is here: It comes last because it fits the native C/C++ or C# code that Lua game scripts often bind to, not the Lua scripts themselves.

Best for
C, C++ and C# engine or binding code beside Lua scripts
Key features
  • Preset styles, with configuration loaded from a .clang-format file in parent directories
  • Can dump a configuration to stdout to bootstrap a .clang-format file
  • Dry-run mode shows what would change without applying it
  • Can format specific line ranges and emit replacements as XML
  • A .clang-format-ignore file makes it skip certain files
Limits
Lua is not among the documented languages, so it cannot replace a Lua formatter. Teams that need Lua coverage should check the vendor documentation or pair it with a Lua-specific tool.
Platforms / deployment
Not stated on official pages
Pricing
See vendor pricing page (not quoted here; facts checked 21 November 2026, Asia/Dhaka)

How we chose these tools

We looked at three things: fit with Lua game scripting and Neovim config work, the capabilities each vendor documents, and the deployment and platform options the documentation lists (binaries, package managers, CI actions, pre-commit hooks, editor integrations). Every fact in this list comes from the official vendor page for that tool, as of the check date recorded for it. Anything a page does not state is left out or marked as not stated.

The order reflects editorial fit for this use case. Tools documented for Lua and its variants come first, followed by multi-language formatters that can cover the surrounding config and scripts. It does not say one tool is better overall, and tools placed later are often the right choice for a different job. The list is built from documentation, not from product trials, so check each vendor's docs for your exact Lua dialect and editor setup before adopting a tool.

Order used in this guide: Ordered by Lua-specific fit, then multi-language formatters covering config files.

Frequently asked questions

What is a good code formatter for Lua?

StyLua is documented specifically for Lua 5.1-5.4, LuaJIT, Luau and CfxLua/FiveM Lua. It is deterministic and mainly follows the Roblox Lua Style Guide.

Can I format Neovim Lua configs with StyLua?

StyLua lists editor integrations for Sublime, Neovim and Zed, and they require the StyLua binary to be installed. It also provides a --check flag to report files needing formatting without rewriting them.

How do I check Lua formatting in CI?

StyLua offers a GitHub Action that installs and runs it, three pre-commit hooks, and a --check flag whose output can be machine-readable JSON. dprint has a similar dprint check command, but its official plugin list on the vendor page does not include Lua.

Can one tool format Lua and my other config files?

dprint aims to be a single formatter for every language in a repository, with official plugins for JSON, Markdown, TOML and more. Its Exec plugin can wrap any other CLI formatter, so a Lua formatter could be called from the same configuration; confirm the details in the vendor documentation.

Do shfmt or clang-format format Lua?

Neither lists Lua. shfmt formats shell scripts, and ClangFormat formats C, C++, Java, JavaScript, JSON, Objective-C, Protobuf and C#.

Sources. Facts on this page come from each vendor's official pages, checked on the dates shown (Asia/Dhaka):

Linthelm is independent and not affiliated with the vendors listed. No vendor paid for inclusion or position. Product names belong to their owners. Features and prices change; confirm details on each official website.