Lua Formatter
Format and validate Lua code online for free with StyLua, right in your browser.
Local browser processing
No sign-up required
Powered by StyLua
LanguageFor Lua scripts
Luascript.lua
Indent
Line width
Quotes
InputEditable
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
OutputLua valid33 lines · 622 B
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
local M = {}
local function clamp(value,min,max)
if value < min then return min
elseif value > max then return max
else return value end
end
function M.new(width, height)
local self = setmetatable({}, {__index = M})
self.width = clamp(width, 1, 9999)
self.height = clamp(height, 1, 9999)
self.tiles = {}
for y = 1, self.height do
self.tiles[y] = {}
for x = 1, self.width do
self.tiles[y][x] = 0
end
end
return self
end
function M:set(x, y, value)
if x >= 1 and x <= self.width and y >= 1 and y <= self.height then
self.tiles[y][x] = value
end
end
function M:get(x, y)
return (self.tiles[y] or {})[x] or 0
end
return M
UTF-8 · 4 spaces · StyLuaLocal processing · Ready
How It WorksLua
Overview
This Lua formatter cleans up code with inconsistent indentation or mixed styles into a standard format, powered by a WebAssembly build of StyLua. It supports space/tab indentation, custom line width, and quote style. Everything runs locally in your browser; your code never leaves your device.
Use Cases
Format Lua code pasted from docs or generated by AIUnify code style for game scripts (LÖVE, Roblox, etc.)Clean up legacy code with inconsistent indentationValidate whether Lua syntax is correct
Steps
123
Paste or uploadChoose optionsGet the result