Remove comments from
Lua code.
Strip comments from Lua scripts online. Handles single-line --, block --[[ ]], and long-bracket string literals correctly.
.lua filesBefore and after
Real-world Lua code on the left. The same code with every comment removed on the right.
-- Player movement script
local Vector3 = require("Vector3") -- 3D math
-- Configuration
local SPEED = 5 -- units per second
local FRICTION = 0.9 -- per frame
--[[
Update is called every frame.
Don't allocate inside it.
]]
function Update(player, dt)
-- Apply input
local move = Vector3.new(0, 0, 0)
if Input.IsDown("w") then move.z = -1 end -- forward
if Input.IsDown("s") then move.z = 1 end -- backward
player.velocity = player.velocity * FRICTION + move * SPEED * dt
end
local sql = [[ SELECT * FROM users WHERE name = "// not a comment" ]]local Vector3 = require("Vector3")
local SPEED = 5
local FRICTION = 0.9
function Update(player, dt)
local move = Vector3.new(0, 0, 0)
if Input.IsDown("w") then move.z = -1 end
if Input.IsDown("s") then move.z = 1 end
player.velocity = player.velocity * FRICTION + move * SPEED * dt
end
local sql = [[ SELECT * FROM users WHERE name = "// not a comment" ]]Built for Lua specifically.
Lua is widely embedded in games, tools, and Redis, and its scripts often carry generous comments because Lua programmers tend to be careful documenters. When you want a compact script for a level configuration, a benchmark, or a teaching example, comment-free is faster to read. Uncommenter handles every Lua comment shape including the long-bracket form.
- -- line comments removed
- --[[ ]] block comments removed
- Long-bracket string literals [[...]] preserved
- Numeric and shebang prefixes handled
- Auto-detected from .lua files
Strip comments in 30 seconds.
- 1
Open the tool
Head to uncommenter.com/tool. Nothing to install. Nothing to sign up for.
- 2
Paste your Lua code
Drop your .lua file in, or paste code into the editor. Auto-detection picks up Lua from the extension or file content.
- 3
Click 'Remove Comments'
The parser walks every character with a real state machine, strings, regex, and other context-sensitive parts are detected and left alone.
- 4
Copy or download
Grab the cleaned output. Your code never left your browser.
Lua questions, answered.
Does it handle long-bracket strings?
+
Yes. [[...]] string literals are recognized, so any -- inside them is preserved as content.
What about Roblox Luau?
+
Luau uses the same comment syntax as standard Lua, line -- and block --[[ ]], so the same engine works on Luau scripts as well.
Are nested block comments supported?
+
Lua's spec doesn't allow nesting at the language level, and the parser matches that, the first matching ]] closes the block.
Working in something else?
Plus 35+ more languages supported in the live tool , including HTML, YAML, Dockerfile, Terraform, Solidity, and more.
Try it on your Lua code now.
Free forever. No signup. No upload. Runs entirely in your browser.
Open uncommenter