Documentation

Learn more about BeautifyLua, its features, and the differences between Lua and Luau.

About BeautifyLua

BeautifyLua is designed to be a simple, fast, and highly-configurable code formatter for both standard Lua (5.1+) and Luau, the dialect used by Roblox. Our goal is to provide a developer-friendly tool that helps maintain a consistent code style across your projects, improving readability and maintainability.

The tool uses a powerful AI model to parse your code and re-print it according to modern best practices, running entirely in your browser to ensure your code remains private and secure.

Lua vs. Luau

While Luau is a superset of Lua 5.1, it introduces several new syntax features and type annotations. BeautifyLua is trained to handle both gracefully.

Type Annotations (Luau)
Luau introduces optional type annotations. BeautifyLua ensures that these annotations are preserved and formatted correctly.
-- Luau with types
local function add(a: number, b: number): number
  return a + b
end
Compound Assignments (Luau)
Luau adds operators like `+=`, `-=`, `*=`, etc. BeautifyLua correctly adds or preserves spacing around these operators.
local x = 10
x += 5 -- x is now 15
Generalized Iteration (Luau)
Luau extends `for` loops with generalized iteration. The formatter maintains the structure of these advanced loops, ensuring readability is not compromised.

When you toggle between Lua and Luau modes in the editor, the formatter adjusts its parsing and formatting rules to accommodate these differences automatically.