Toolsify.dev

Lua Beautifier

Format Lua code in your browser with StyLua. Choose a supported syntax mode and indentation, then copy the formatted result.

Lua source

Source stays in this browser. Tab moves focus; use spaces or paste tab characters for indentation. Maximum input size is 128 KiB.

Formatted Lua

Format Lua in your browser

Paste source, choose its syntax mode and style options, then select Beautify. The formatted result appears separately so the original source remains available. Copy output when it is ready.

StyLua parses and prints the selected syntax. It does not execute Lua, inspect runtime behavior, type-check code, or repair programs. Formatting output uses LF line endings; the selected line width is a wrapping guide, not a hard limit.

Supported syntax

Select Lua 5.1, 5.2, 5.3, 5.4, LuaJIT, Roblox Luau, or CfxLua/FiveM Lua. These are parser modes; support covers syntax understood by the pinned StyLua version, not every runtime API or every future dialect extension.

Lua 5.5 is not a supported mode. If the selected parser reports a syntax error, check that the syntax selection matches your source. The formatter does not silently retry another mode.

Formatting options

Choose 2 spaces, 4 spaces, or tabs for indentation and an approximate line width of 80, 100, or 120 characters. StyLua may keep some lines longer when the syntax requires it. Require sorting is disabled.

Before and after

Before formatting

local function greet(name)print('Hello, '..name)end

After formatting

local function greet(name)
  print("Hello, " .. name)
end

Privacy and errors

Formatting runs locally in this browser after the WebAssembly formatter loads. Your source is not sent to a formatting server. Syntax diagnostics come from StyLua; they do not indicate whether code will run correctly.

StyLua is distributed under the MPL-2.0 license. See the StyLua source and license.

What is Lua code formatting?

Lua code formatting applies a consistent layout to source code while keeping the source readable as Lua. StyLua reads the selected syntax and prints blocks, expressions, tables, function calls, and comments using its formatting rules. This can help when inspecting a compact script, reviewing a configuration change, or preparing a Lua file for a code review.

A formatter is different from a linter or runtime. It focuses on code layout; it does not decide whether a variable is a good name, whether a game API exists, or whether a program behaves as intended. StyLua’s full output verification checks its formatted output against the parsed syntax tree, but this is not a proof of runtime correctness or semantic equivalence.

How to use the Lua formatter

  1. Paste the Lua source into the editor. The source is kept separate from the formatted result.
  2. Choose the closest syntax mode for your project, such as Lua 5.4, LuaJIT, Roblox Luau, or CfxLua/FiveM Lua.
  3. Choose 2-space, 4-space, or tab indentation and an approximate line-width preference.
  4. Select Beautify. The formatter loads its WebAssembly engine on the first request and performs formatting in a browser worker.
  5. Review the result, then select Copy output. To start over, use Clear; to restore the default settings without removing source, use Reset options.

The input limit is 128 KiB in UTF-8. If an input exceeds that size, it stays in the source editor and the formatter asks you to reduce its size. The tool does not send the input to a server to process it.

Choosing a Lua syntax mode

Lua dialects share much of their syntax, but they also contain differences. Selecting the mode helps the parser interpret code that is specific to a language version. For example, Lua 5.2 includes labels and goto, Lua 5.3 adds integer division and bitwise operators, and Lua 5.4 includes local variable attributes such as <const> and <close>.

LuaJIT, Luau, and CfxLua also have parser modes because projects in those environments can use syntax extensions. A successful format means the selected StyLua parser could process the input. It does not mean Roblox or FiveM APIs are available, or that every version of those dialects is covered. Lua 5.5 has no mode in this tool; do not select Lua 5.4 as a substitute for Lua 5.5-specific syntax.

Indentation, line width, and output

Choose indentation based on the conventions in your project. Two spaces and four spaces produce space-based indentation; Tabs uses tab characters for indentation. The line-width setting guides when StyLua wraps expressions and calls. It is approximate, so long strings, comments, or syntax that cannot be sensibly split can still extend beyond the chosen width.

Formatted output uses LF line endings. StyLua may normalize spacing, line breaks, and quote presentation as part of printing. Require sorting is disabled, and the tool provides no option to bypass full output verification. The formatter does not offer a mode that replaces the source editor; review and copy the separate result instead.

Understanding Lua syntax errors

If the selected parser cannot parse the source, the formatter shows StyLua’s diagnostic and any location it provides. Check that the selected mode matches the project’s syntax and inspect the nearby code. The formatter does not silently retry another mode, remove unsupported syntax, or generate a partial formatted result.

A parser diagnostic is about syntax accepted by the selected mode. It does not check imports, variables, types, game-engine functions, application configuration, or runtime behavior. A script can format successfully and still contain a program error.

Browser processing and source privacy

The formatter’s JavaScript and WebAssembly code are loaded from this site when you first format nonempty source. Formatting then happens in a dedicated browser worker. The Lua text itself is not submitted to a formatting API or server. The page can still load ordinary site resources and send the site’s normal page-level analytics request; the source text is not included in that request.

Because processing stays in the browser, a compatible browser with WebAssembly and worker support is required. If the formatter asset fails to load, check the connection and retry. The tool does not execute source code while formatting.

Lua Beautifier FAQs

Answers about Lua syntax modes, formatting options, and browser processing