Lua Formatter (StyLua)

Paste messy Lua or Roblox Luau code and get it back with consistent indentation, spacing, and quotes. The formatter is StyLua, running in your browser, so your code stays on your device.

Indent
Quotes

Format uses StyLua. The indent and quote options apply to Format.

Result

What a Lua formatter does

Lua does not care about indentation or line breaks, so code copied between games, mods, and config files often ends up hard to read. A formatter, also called a beautifier, rewrites the code with one consistent layout: every function, loop, and if block indented the same way, even spacing around operators, and one quote style for strings. This tool uses StyLua and changes only the layout, never what the code does.

Why use our Lua formatter

  • ·Free. No signup, no paywall, no limits.
  • ·Runs in your browser. StyLua runs locally as WebAssembly, so your code is never uploaded.
  • ·Roblox ready. Formats Luau, including type annotations.
  • ·Finds errors. Syntax errors are shown with their line and column.
  • ·Your house style. Choose tabs or spaces and the quote style your project uses.

Lua formatter options

Format

Rewrites your Lua with consistent indentation and spacing using StyLua. Function bodies, loops, and if blocks are indented, and long tables and calls are wrapped.

Beforelocal function f(a,b) return a+b endAfterlocal function f(a, b) return a + b end

Indent

Choose tabs, 2 spaces, or 4 spaces for each level of nesting. Tabs is StyLua's default and what Roblox Studio uses. Many Neovim configs use 2 spaces.

BeforeTabs, 2 spaces, or 4 spacesAfterYour choice per level

Quotes

Prefer double or Prefer single picks one quote style but switches when that avoids escaping a quote inside the string. Always double and Always single use one style everywhere.

Beforeprint('hi')Afterprint("hi")

Who uses a Lua formatter

Lua shows up in games, editors, and embedded tools. These are the people who format it most:

  • ·Roblox developers. Clean up scripts before sharing them or asking for help.
  • ·Neovim users. Format init.lua and plugin configs so they are easy to read.
  • ·Game modders. Make LÖVE games and World of Warcraft or Garry's Mod addons readable.
  • ·Learners. See how well-structured Lua is laid out while you are learning.

Learn more about Lua

These references explain the language and the formatter behind this tool:

Run StyLua on your own Lua code

This tool uses StyLua, the most popular Lua formatter, compiled to run in your browser. To format your own project the same way:

ToUse
Format every Lua filestylua .
Check without changing filesstylua --check .
Save your settingsCreate a stylua.toml with indent_type = "Spaces", indent_width = 2, and quote_style = "AutoPreferDouble"
Install itDownload it from the StyLua GitHub releases page, or run cargo install stylua

When a stylua.toml file is in your project, StyLua uses it automatically, so everyone on the team gets the same layout without passing any options.

If you work across languages, these formatters run the same way, right in your browser:

Frequently asked questions

What is StyLua?
StyLua is the most widely used code formatter for Lua. It reads your code and prints it back with one consistent layout, much like Prettier does for JavaScript. This tool runs StyLua, compiled to WebAssembly, in your browser.
How do I format Lua code online?
Paste your Lua into the input box, pick your indentation and quote style, then click Format. The clean version appears below. Click the copy button to copy it, or download it as a .lua file.
Can I format Roblox scripts?
Yes. StyLua understands Luau, the version of Lua that Roblox uses, including type annotations and compound operators like +=. Paste your script from Roblox Studio, format it, and paste it back.
Does formatting change how my code runs?
No. Formatting only changes indentation, spaces, line breaks, and the quote characters around strings. The string values themselves stay the same, so your code runs exactly as before.
Which versions of Lua are supported?
Lua 5.1, 5.2, 5.3, and 5.4, LuaJIT, and Luau. That covers Roblox, LÖVE, Neovim configs, World of Warcraft addons, and most other places Lua is used.
Is my Lua code kept private?
Yes. StyLua runs entirely in your browser as WebAssembly. Your code is never uploaded to a server or saved anywhere, so you can safely paste in code from a private project. Once the page has loaded you can even use it offline.