Skip to content
Quasar Tools Logo

Best Lua Formatter Extensions for VS Code

The top Lua formatter extensions for VS Code compared — setup, config, formatting rules, and a browser-based fallback when you cannot install extensions.

DH
Tips & Best Practices11 min read2,600 words

Unformatted Lua code accumulates fast — inconsistent indentation, mismatched spacing around operators, and blocks that differ between team members. The right VS Code extension fixes all of that automatically. This guide covers the top Lua formatter extensions for VS Code in 2026, how to set each one up, how to configure format-on-save, and what to use when you cannot install extensions at all.

3+Major Lua formattersFor VS Code in 2026
1M+Lua LS installsMost-used Lua extension
< 5sSetup timeFrom zero to format-on-save

Why formatting matters for Lua

Lua has no enforced style standard. The language parser accepts any valid indentation, any operator spacing, and any block layout — which means every developer defaults to their own habits. In a solo project that is fine. In a shared codebase, game mod, or team script repository, inconsistent formatting creates noise in every diff, slows down code review, and makes debugging harder than it needs to be.

The cost of inconsistent Lua style

When two people write Lua differently — one uses four-space indentation, one uses tabs; one spaces around operators, one does not — every commit contains formatting changes mixed with logic changes. Reviewers spend time reading style diffs instead of logic diffs. Merge conflicts spike. A formatter solves this by normalising every file to the same style on save, making diffs clean and reviewable.

  • Consistent indentation — `do`/`end`, `if`/`end`, `function`/`end` blocks all indent the same way every time
  • Uniform spacing — spaces around `=`, `+`, `-`, `..` and other operators are applied consistently
  • Blank line discipline — extra blank lines between functions and inside loops are normalised automatically
  • Readable string handling — long string concatenations and multiline strings are laid out predictably
  • Team-wide enforcement — a shared `.luarc.json` or `stylua.toml` in version control guarantees everyone uses the same rules

Note

Formatting is distinct from linting. A formatter only changes whitespace and layout — it never alters logic. A linter like [Lua Syntax Validator](/tools/data/validators/lua-syntax-validator) catches semantic errors, undefined variables, and logic problems. You need both.

Top Lua formatter extensions for VS Code

The VS Code Marketplace has several Lua extensions, but only a handful are actively maintained and provide reliable formatting. Here are the three worth knowing in 2026, in order of recommendation.

The Lua Language Server, published as `sumneko.lua` on the VS Code Marketplace, is the single most complete Lua development tool available for VS Code. It installs a full Language Server Protocol (LSP) implementation that provides diagnostics, type inference, go-to-definition, hover documentation, workspace-wide find references, and a built-in formatter — all in one extension.

  • Publisher: sumneko (Tang Liu)
  • Marketplace ID: `sumneko.lua`
  • Active installs: 1M+ (as of 2026)
  • Lua versions supported: 5.1, 5.2, 5.3, 5.4, LuaJIT
  • Formatter: Built-in, configured via `.luarc.json`
  • Format-on-save: Supported natively
  • Best for: Most Lua workflows — game scripting, standalone tools, embedded systems

Tip

Lua Language Server is also the recommended base for Roblox development when combined with the `roblox-lua-lsp` type definitions package, which adds Roblox services, instances, and Luau-specific globals to the type checker.

2. StyLua (jq-steuersoftware.stylua) — opinionated alternative

StyLua is an opinionated Lua code formatter written in Rust, inspired by Prettier. The VS Code extension wraps the StyLua binary and integrates it as a document formatter. Unlike Lua Language Server, StyLua is a formatter-only tool — it does not provide diagnostics, hover documentation, or code completion. What it does provide is a deterministic, zero-debate style: you agree to the style and commit to it, the same way Prettier works for JavaScript.

  • Publisher: jq-steuersoftware
  • Marketplace ID: `jq-steuersoftware.stylua`
  • Lua versions supported: 5.1, 5.2, 5.3, 5.4, LuaJIT, Luau (Roblox)
  • Config file: `stylua.toml` (optional — works well with defaults)
  • Format-on-save: Supported natively
  • Best for: New projects, teams that want Prettier-style zero-config formatting, Roblox Luau development

3. LuaFormatter (Koihik.vscode-lua-format) — configurable legacy option

LuaFormatter is an older extension that wraps the `lua-format` command-line tool. It provides extensive configuration — you can tune indent width, max line length, operator spacing, continuation indent, and many other rules individually. This level of control makes it useful when migrating an existing codebase that already has an established style convention you need the formatter to honour. However, development has slowed since StyLua emerged, and the underlying `lua-format` binary requires a separate install step on some platforms.

  • Publisher: Koihik
  • Marketplace ID: `Koihik.vscode-lua-format`
  • Config file: `.lua-format` (YAML format)
  • Best for: Existing codebases with complex style requirements, granular per-rule control
  • Caveat: Requires `lua-format` binary installed separately on Linux/Mac

Warning

LuaFormatter (Koihik.vscode-lua-format) has seen declining maintenance since 2023. For new projects, start with Lua Language Server or StyLua. Only reach for LuaFormatter if your team specifically needs its granular configuration options.

How to set up Lua LS in VS Code

Installing Lua Language Server takes under two minutes. Here is the complete setup path from a fresh VS Code install to working format-on-save.

1

Install Lua Language Server from the Marketplace

Open VS Code and press Ctrl+P (Cmd+P on Mac) to open the Quick Open bar. Type `ext install sumneko.lua` and press Enter. VS Code downloads and installs the extension automatically. No additional binaries are required — the language server binary is bundled with the extension.

2

Open a .lua file and trigger formatting

Open any `.lua` file in your project. Press Shift+Alt+F (Shift+Option+F on Mac) to run Format Document. On first use, VS Code displays a prompt asking you to select a default formatter for Lua files — choose Lua Language Server. The file formats immediately and the selection is saved to your user settings.

3

Create a .luarc.json for project-level configuration

Create a `.luarc.json` file at your project root to control formatting rules and language server behaviour consistently across your team. Commit this file to version control so every contributor gets identical settings. A minimal starting config targets Lua 5.4 and disables the undefined-global diagnostic for projects with custom globals.

.luarc.json
json
{
  "Lua.runtime.version": "Lua 5.4",
  "Lua.diagnostics.globals": ["myGlobal", "anotherGlobal"],
  "Lua.format.enable": true,
  "Lua.format.defaultConfig": {
    "indent_style": "space",
    "indent_size": "4",
    "max_line_length": "120",
    "trailing_table_separator": "smart"
  }
}
4

Enable format-on-save

Open VS Code settings with Ctrl+, (Cmd+, on Mac), search for `format on save`, and toggle Editor: Format On Save to enabled. From now on, every time you save a `.lua` file, the formatter runs automatically. To scope this setting only to Lua files without enabling it globally, add it to your project's `.vscode/settings.json` instead.

.vscode/settings.json
json
{
  "editor.formatOnSave": true,
  "[lua]": {
    "editor.defaultFormatter": "sumneko.lua"
  }
}

Lua Formatter — Browser-Based

Format Lua code instantly in your browser with no extensions or installs needed — paste your code and get clean, indented output in seconds.

Open tool

Configuring format-on-save

Format-on-save is the most impactful single setting you can enable for Lua development in VS Code. Once active, you never manually trigger the formatter — it runs every time you hit Ctrl+S. Here is how to configure it correctly for different team scenarios.

User-level vs. workspace-level settings

VS Code has two levels of settings: user-level (applies to all projects) and workspace-level (applies only to the current project). For formatting, the workspace level is almost always the right choice — it ensures every contributor on the project uses the same formatter, regardless of their personal user-level preferences. Workspace settings live in `.vscode/settings.json` at the project root and should be committed to version control.

Format-on-save for StyLua

StyLua's VS Code extension uses the same format-on-save mechanism. Set the default formatter to `jq-steuersoftware.stylua` in your workspace settings. StyLua reads a `stylua.toml` config file if present — this is where you set column_width, indent_type, indent_width, and quote_style. Without a `stylua.toml`, StyLua applies its default rules (two-space indent, 120-character line length, double quotes).

stylua.toml
toml
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 4
quote_style = "AutoPreferDouble"
call_parentheses = "Always"

Tip

Committing both `.vscode/settings.json` and your formatter config file (`.luarc.json` or `stylua.toml`) ensures that any contributor who opens the project in VS Code gets identical formatting behaviour from the first file save — no onboarding instructions required.

Excluding files from formatting

Some Lua files should not be reformatted — vendor libraries, generated code, or minified scripts. In StyLua, add a `.styluaignore` file (same syntax as `.gitignore`) to exclude paths. In Lua Language Server, you can scope the formatter to specific directories using the `Lua.workspace.ignoreDir` setting in `.luarc.json`.

LuaFormatter vs StyLua compared

The two most-discussed Lua formatters are LuaFormatter and StyLua. They take fundamentally different approaches to formatting philosophy, and the right choice depends on your project context. Here is a direct comparison.

AspectLuaFormatter (Koihik)StyLua
PhilosophyHighly configurableOpinionated (Prettier-style)
Config file`.lua-format` (YAML)`stylua.toml` (TOML, optional)
Config rules30+ individual options~6 core options
Luau / Roblox✗ Not supported✓ Native Luau support
Binary install✗ Separate step on some OS✓ Bundled with VS Code ext
CI/CD use✓ Via lua-format CLI✓ Standalone binary
Active maintenance✗ Slowed since 2023✓ Actively maintained
Best forExisting codebases with existing styleNew projects, Roblox Luau

If you are starting a new project, pick StyLua and commit the config. If you are inheriting a codebase with an existing style, configure LuaFormatter to match it. Never mix both formatters on the same codebase.

Lua formatting rule of thumb

Lua Language Server vs. StyLua: can they coexist?

Lua Language Server and StyLua serve different primary purposes — Lua LS is a full language server for diagnostics and intellisense, StyLua is a formatter only. They can coexist in the same VS Code setup: install Lua LS for diagnostics and code intelligence, then set StyLua as the default formatter for document formatting. This combination gives you the best of both tools. Configure it in .vscode/settings.json by setting the [lua] defaultFormatter to jq-steuersoftware.stylua while keeping Lua LS installed for its LSP features.


Lua LS built-in formatter: when it is enough

For most developers, the Lua Language Server's built-in formatter is sufficient and removes the need to install a second extension. It handles all standard formatting tasks and integrates cleanly with `.luarc.json`. The main reason to add StyLua on top is if your team wants stronger style enforcement (e.g. enforcing specific quote style or call parentheses conventions) that Lua LS's formatter does not currently support.

Online Lua formatter as a fallback

VS Code extensions are the right solution for day-to-day development. But there are scenarios where you need to format Lua code without installing anything at all — and that is where a browser-based tool fills the gap cleanly.

When you cannot install extensions

  • Shared or locked-down machines — corporate workstations, lab computers, or CI environments where you cannot install VS Code extensions
  • Quick one-off cleanup — a colleague sends you a Lua snippet to review and you want it formatted without switching context
  • Code review without a dev environment — reviewing a pull request on a machine where your full Lua setup is not configured
  • Onboarding checks — verifying a file looks correctly formatted before committing without waiting for the full toolchain to install
  • Minified code inspection — you have a Lua minifier output and want to reformat it for readability

The Quasar Tools Lua Formatter handles all of these cases. Paste your Lua code into the editor and the formatter applies consistent indentation, normalises operator spacing, and cleans up blank lines in your browser — with no signup, no install, and no data ever leaving your device.

Complementary online Lua tools

Formatting is one step in a complete Lua code quality workflow. Several other browser-based tools cover adjacent tasks you will regularly need alongside formatting:

  • **Lua Beautifier** — focuses on improving the visual layout of code that is syntactically correct but hard to read
  • **Lua Syntax Validator** — checks code for parser-level errors with line-level diagnostics before you run it
  • **Lua Minifier** — strips comments, whitespace, and blank lines for production deployment to reduce script file size
  • **Lua Obfuscator** — renames variables and encodes strings to protect game scripts from casual reverse engineering
  • **Lua Deobfuscator Helper** — improves readability of obfuscated scripts for debugging and analysis workflows

Lua Beautifier

Clean up Lua code with proper indentation, spacing, and line breaks in your browser — no extensions, no install, no uploads.

Open tool

Lua formatting best practices

A formatter handles whitespace, but good Lua code quality goes further. These practices work alongside your formatter to keep Lua codebases consistent, readable, and maintainable at any scale.

Commit your formatter config to version control

A `.luarc.json` for Lua LS, `stylua.toml` for StyLua, or `.lua-format` for LuaFormatter should all live at the project root and be committed to your repository. This ensures every contributor — and every CI run — uses identical formatting rules. Without a committed config, each developer defaults to their own extension settings and formatting divergence creeps back in over time.

Add a CI formatting check

Format-on-save in VS Code only helps people who use VS Code and have the extension installed. A CI check catches anything that slips through — contributors using other editors, quickly patched files, or generated Lua code. StyLua's `--check` flag exits with a non-zero code if any file is not correctly formatted, making it easy to fail a GitHub Actions or GitLab CI job on style violations.

Separate formatting commits from logic commits

If you are introducing a formatter to an existing codebase for the first time, run the formatter across all files in a single dedicated commit with no other changes. Label it clearly (e.g. `chore: apply lua formatter to all files`). This keeps the formatting noise in one commit so that all subsequent commits contain only logic changes — and `git blame` remains useful on every line.

Tip

Validate your Lua syntax before and after running a new formatter for the first time. The [Lua Syntax Validator](/tools/data/validators/lua-syntax-validator) will surface any parser errors immediately, so you know the formatter output is safe to commit.

Use consistent local variable naming

Formatters do not rename variables — that is your responsibility. The Lua community largely follows `snake_case` for variables and functions and `PascalCase` for module-level tables and class-like constructs. Agree on a convention with your team and document it in your project's `CONTRIBUTING.md`. If you work with Roblox Luau, the Roblox style guide specifies `PascalCase` for instances and services and `camelCase` for local variables — be aware of the distinction before applying Lua-community conventions blindly.

Warning

Be cautious running formatters on obfuscated Lua files. Obfuscated scripts intentionally use unusual formatting and naming to resist analysis. Reformatting them may alter string encodings or break intentionally compressed single-line blocks. If you need to read obfuscated Lua, use the [Lua Deobfuscator Helper](/tools/data/obfuscators/lua-deobfuscator-helper) first — not a formatter.

Key takeaways

  • The Lua Language Server (sumneko.lua) is the best all-round Lua extension for VS Code — it includes formatting, diagnostics, type inference, and code intelligence in one install.
  • StyLua is the best formatter-only choice for new projects and Roblox Luau development, offering opinionated Prettier-style consistency with minimal config.
  • LuaFormatter is a configurable legacy option suited to existing codebases that need granular style control, but it is less actively maintained than the alternatives.
  • Commit your formatter config (.luarc.json or stylua.toml) to version control so all contributors get identical formatting behaviour automatically.
  • Add a CI formatting check with StyLua --check to catch unformatted files before they merge, regardless of which editor contributors use.
  • The Quasar Tools Lua Formatter handles quick one-off formatting in a browser tab — no extensions, no installs, no server uploads required.
  • Never run a standard formatter on obfuscated Lua; use the Lua Deobfuscator Helper first to restore readability before formatting.

Frequently Asked Questions

The best Lua formatter for VS Code in 2026 is the Lua Language Server (sumneko.lua), published by sumneko. It is the most actively maintained, installs a full LSP with diagnostics, type inference, and formatting built in. It supports .luarc.json for project-level configuration and works out of the box for most Lua workflows including Roblox, LÖVE, and standalone scripting. StyLua (jq-steuersoftware.stylua) is a strong alternative if you want an opinionated, deterministic formatter focused purely on style consistency.

Open VS Code settings with Ctrl+, (Cmd+, on Mac), search for "format on save", and enable Editor: Format On Save. Then confirm that the Lua Language Server (or your preferred Lua formatter extension) is set as the default formatter for .lua files. You can also set this per-workspace in your .vscode/settings.json file by adding: "editor.formatOnSave": true and "[lua]": {"editor.defaultFormatter": "sumneko.lua"}.

Yes. The Lua Language Server (sumneko.lua) includes a built-in formatter that handles indentation, spacing around operators, blank line management, and consistent block structure. It is configured via .luarc.json in your project root. The formatter is not as opinionated as StyLua but gives you much more control over individual rules, which makes it preferred for teams with existing Lua codebases that have established style conventions.

StyLua is an opinionated Lua code formatter inspired by Prettier. It enforces a consistent style with minimal configuration — you don't configure individual rules, you accept the style. This makes it ideal for new projects and teams that want zero formatting debates. LuaFormatter is an older, more configurable tool that lets you fine-tune indent size, max line width, operator spacing, and more. Use StyLua for new greenfield projects; use LuaFormatter when you need granular control over an existing codebase.

Yes. The Quasar Tools Lua Formatter runs entirely in your browser with no installation required. Paste your Lua code into the editor and the formatted output is ready instantly — no extension, no terminal command, no VS Code needed. This is especially useful on shared or locked-down machines, in CI workflows where you just need a quick check, or when reviewing someone else's Lua code on a machine where you have not set up your development environment.

The standard Lua Language Server extension (sumneko.lua) supports Lua 5.1–5.4 and LuaJIT. For Roblox Luau specifically, the recommended approach is to install the "Roblox LSP" extension or use Rojo with the roblox-lua-lsp setup, which extends the Lua Language Server with Roblox-specific globals, services, and Luau type syntax. Formatting for Roblox scripts works with StyLua as well, since StyLua supports Luau syntax natively.

A .luarc.json file is the project-level configuration file for the Lua Language Server extension. It sits at the root of your project and tells the language server how to behave: which Lua version to target (5.1, 5.2, 5.3, 5.4, or LuaJIT), which globals exist, what workspace libraries to load, and what formatting rules to apply. Committing .luarc.json to version control ensures every team member gets identical language server and formatter behaviour regardless of their local VS Code settings.

StyLua is the best choice for CI because it is available as a standalone binary with no runtime dependency. Download the StyLua binary for your CI platform, add a step that runs "stylua --check ." to verify formatting, and fail the pipeline on any style violations. LuaFormatter can also be used via the command line with "lua-format --check". For a quick no-install check during code review, the Quasar Tools Lua Formatter at quasartools.com/tools/data/formatters/lua-formatter handles the job in a browser tab.

ShareXLinkedIn

Related articles