Online Lua - IDE, Editor, Compiler, Interpreter

Run Lua 5.4 scripts instantly with a WebAssembly build of the reference interpreter. Ideal for learning Lua or testing game and config scripts.

Lua 5.4 (wasmoon) · Runs in your browser, so your code never reaches our servers.
main.luaLua
Output

            
        
Ctrl/⌘ + Enter to run

Features of the online Lua compiler (IDE, editor & interpreter)

Write, run and test Lua code online for free. This page works as an online Lua IDE, code editor, compiler and interpreter in one: type your code, press Run and see the output straight away. Everything runs in your browser, with nothing to install and no account to create.

  • Run code instantly: Lua 5.4 (wasmoon), with output in under a second after the first load.
  • Code editor: syntax highlighting, line numbers, bracket matching and auto-closing brackets.
  • Clear errors: error messages and warnings appear in the output panel, as they would on your own computer.
  • Full screen: Ctrl/⌘ + Shift + F, adjustable font size, side-by-side or stacked layout and resizable panes.
  • Autosave: your code is kept in your browser; download it as main.lua or copy it in one click.
  • Safe to experiment: a time limit and a Stop button end infinite loops.
  • Private: the Lua runtime runs on your device, so your code is never uploaded.
  • Dark mode and keyboard shortcuts: Ctrl/⌘ + Enter runs the code.
  • Free: no sign-up, no usage limits.

Learn other programming languages

How to use the online Lua compiler

  1. Write or paste a Lua script into the editor. Reset example restores the starter code.
  2. Press Run or use Ctrl + Enter (⌘ + Enter on a Mac).
  3. Everything you pass to print() appears in the Output panel. Like the standard interpreter, multiple arguments are separated by tabs, and nil is printed as nil. Runtime and syntax errors are highlighted along with the line number.
  4. Choose a time limit of 5, 15 or 60 seconds. A script that runs too long is stopped automatically, and Stop ends it immediately.

The Lua runtime is small, well under 1 MB, so the page is ready to run almost instantly. Use Copy or main.lua to save your script.

Your script runs in a Web Worker inside your browser. It is never uploaded and is not stored on our servers. The editor remembers your last code in your browser's local storage, and in no other place.

What's supported

The compiler runs Lua 5.4 through wasmoon, a WebAssembly build of the reference Lua interpreter written in C. Your code is executed by real Lua, not by a translation into JavaScript.

  • The Lua 5.4 language: integer and float subtypes, integer division (//), bitwise operators, goto, and the <const> and <close> local attributes.
  • Standard libraries: string (including Lua patterns and string.format), table, math, utf8 and coroutine.
  • Closures, metatables and coroutines, so you can practise object-oriented and generator-style Lua.

Limitations:

  • Use print() for output. Output is captured from print, so use it rather than io.write.
  • No standard input, network access or real files. Put your test data directly in the script.
  • No C modules or LuaRocks. Only pure Lua code in the editor can run.
  • Each run gets a fresh Lua state, so globals from the previous run are cleared.

Lua quick reference

local Account = {}
Account.__index = Account

function Account.new(owner, balance)
  return setmetatable({ owner = owner, balance = balance or 0 }, Account)
end

function Account:deposit(v)
  self.balance = self.balance + v
end

local acc = Account.new("Ada")
acc:deposit(50)
print(acc.owner, acc.balance)          --> Ada  50

for word in ("one two three"):gmatch("%a+") do
  print(#word, word:upper())
end
print(7 // 2, 7 / 2)                   --> 3  3.5
TaskSyntax
Local variablelocal x = 10
Concatenate strings"a" .. "b"
Length of a string or list#t
Not equala ~= b
Numeric loopfor i = 1, 10, 2 do ... end
Iterate a list / a tablefor i, v in ipairs(t) / for k, v in pairs(t)
Format a numberstring.format("%.2f", n)

Tips

  • Lua arrays start at index 1, not 0, and # is only reliable for sequences without nil holes.
  • Declare variables with local. Without it, a variable is global, which is slower and a common source of bugs.
  • Only nil and false are falsy. 0 and the empty string are true in Lua.
  • Lua patterns look like regular expressions but are simpler, and use % instead of a backslash, as in %d+. For full regular expressions in other languages, try the regex tester.
Tip: To print a table's contents, loop over it with pairs, or use table.concat(list, ", ") for a list of strings and numbers. Passing the table itself to print(t) does not list its contents.

Frequently asked questions

Which Lua version does this use?

Lua 5.4. Run print(_VERSION) to confirm. Code written for Lua 5.3 almost always works unchanged, while Lua 5.1 or LuaJIT code may need small changes, for example replacing unpack with table.unpack.

Can I test Roblox or LÖVE scripts here?

You can test plain Lua logic, such as functions, tables, string handling and maths. Engine APIs like Roblox services (Roblox uses its own Luau dialect) or LÖVE's love.* functions do not exist here.

Why doesn't io.read work?

The compiler has no interactive standard input. Define your test values as variables at the top of the script.

What other languages can I run online?

The online Python compiler and the online Ruby compiler also run entirely in your browser.

Copied to clipboard