Format Code Now
/

Lua Minifier and Beautifier

WM-95

Paste Lua to shrink it by removing comments and whitespace, or press Beautify to lay it out again. Strings and long strings are never touched.

Runs in your browser. Nothing is uploaded.

Lua code

Result

How to use it

  1. Paste your Lua, or open a .lua file or drop it on the input box.
  2. Press Minify to shrink the code.
  3. Or press Beautify to re-format it with indentation.
  4. Copy the result or download it as a .lua file.

How Minify works

Minify splits the code into tokens, drops comments, and joins the rest with the smallest spacing that keeps the tokens unchanged. Short strings, long strings written with double brackets and numbers are copied exactly, and a first line starting with #! is kept. Names are not shortened, no code is removed, and the result runs the same. It is a size reducer, not an obfuscator.

Beautify

Beautify uses a Lua formatter compiled to WebAssembly. It re-lays out the code with indentation and spaces around operators, and it can move line breaks. It indents with tabs. Comments are kept. Because the formatter may need to read the structure, code with a missing end, then or do can fail with an error.

Errors and limits

Minify reports an unclosed string or comment with its line and column. Neither action runs the code or finds undefined variables. For game scripts and embedded Lua, test the minified file before using it, as with any transformation. Always run the minified script once before shipping it.

Error messages and what to do

MessageWhat it meansFix
String is never closed (missing ") (line 1, column 7).A quoted string has no closing quote before the line ends.Add the missing quote at the position shown.
Long comment starting here is never closed (missing ]]) (line 1, column 3).A long comment was opened with --[[ and never closed.Add ]] to end the comment.
Could not format the Lua: the code has a syntax error. Check for a missing end, then or do.The Beautify formatter could not parse the code.Look for a missing end, then or do, and try again.

Questions people ask

How do I minify Lua code?

Paste the code and press Minify. Comments, blank lines and extra spaces are removed, and strings stay exactly as written. Paste the code and press Minify. Comments, blank lines and extra spaces are removed, and strings stay exactly as written. Copy the result or download it as a .lua file.

Does Minify rename my variables?

No. Local and global names are unchanged. The saving comes from whitespace and comments only. No. Local and global names are unchanged and no code is removed. The saving comes from whitespace and comments only, so the minified file is easy to compare.

Will long strings and comments with brackets survive?

Long strings in double brackets are kept exactly. Long comments are removed, including the ones that use a level of equals signs. Long strings in double brackets are kept exactly, including their line breaks. Long comments are removed, including ones that use equals signs between the brackets.

Is minified Lua the same as obfuscated Lua?

No. Minified code is only compacted and still readable with effort. This tool does not obfuscate. No. Minified code is only compacted and can still be read with effort. This tool does not obfuscate or rename anything, and it is not meant to hide code.

Why does Beautify show an error?

The formatter could not parse the code, often because of a missing end, then or do. Fix the structure and try again. The formatter could not parse the code, often because of a missing end, then or do. Fix the structure and try again. Minify has its own checks for strings and comments.

About this tool

Minify removes comments and whitespace and keeps strings and long strings exactly as written. A space or line break stays only where removing it would change the tokens. It does not rename variables, remove unused code or rewrite expressions, so the saving comes from comments and whitespace alone. It is not an obfuscator. Beautify uses a Lua formatter compiled to WebAssembly in your browser and re-lays out the code, which can move line breaks. Neither action runs the code; unclosed strings and comments give an error with line and column.

Format Code Now: free, no ads, no accounts. Your input stays in your browser.