Lua Playground

Lua 5.4 (WASM)

Execute Lua 5.4 scripts in your browser memory with WebAssembly. Test tables, metatables, closures, and string patterns with instant terminal output.

main.lua
0 lines · 0 chars Lua
Lua stdout Output
Ctrl/Cmd+Shift+C
Click "Run" (⌘↵) to execute Lua program.
Ready Terminal

About This Tool

This runs real Lua 5.4 scripts through Fengari, a Lua VM compiled to WebAssembly/JavaScript, entirely in your browser tab. It's useful for testing table and metatable logic, coroutines, or string pattern matching without installing a Lua interpreter locally.

There's no execution timeout, so a genuine infinite loop will freeze the tab (reload to recover). For JavaScript/TypeScript logic instead, use JavaScript / TypeScript Playground.

Key Features

  • Four bundled snippets: Tables & Dictionaries & Loops, Metatables & OOP Inheritance, Coroutines & Generators, and String Pattern Matching.
  • print() bridged to the terminal: every call is routed through a Lua-to-JS shim and rendered in call order.
  • Per-run execution timer: a badge showing elapsed milliseconds for the last run.
  • Runtime error capture: syntax and nil-index errors are caught and shown in red instead of crashing the tab.
  • Copy Output / Clear terminal: manage output independently of the editor.
  • Lua Version selector: a display label only; execution always runs on the loaded Fengari 5.4 engine.

Example

Running the built-in "String Pattern Matching" snippet:

local log = "2026-09-02 21:05:00 [ERROR] Connection timeout on worker-04"
local date, time, level, msg = log:match("(%d%d%d%d%-%d%d%-%d%d) (%d%d:%d%d:%d%d) %[(%a+)%] (.*)")

print("Log Extraction Results:")
print(" Date:  " .. (date or "-"))
print(" Time:  " .. (time or "-"))

prints to the stdout terminal:

Log Extraction Results:
 Date:  2026-09-02
 Time:  21:05:00
 Level: ERROR
 Message: Connection timeout on worker-04

FAQ

Which Lua engine actually runs the code?
Fengari, a Lua 5.4 VM compiled to WebAssembly/JavaScript, loaded lazily from a CDN on first run and executed entirely in your browser tab.
What does print() output where?
print is bridged through a small Lua-to-JS shim so every call is captured and rendered in the stdout terminal panel on the right, in call order.
Does the Lua Version or Snippets dropdown change the runtime?
The Snippets dropdown swaps in one of four ready-made example scripts (tables, metatables, coroutines, or string patterns). The Lua Version selector is a label only, execution always runs through the loaded Fengari 5.4 WASM engine.
Is my code sent to a server to execute?
No. Aside from the one-time Fengari script download from a CDN, all parsing and execution happen client-side; your source code and output never leave your browser.
What happens if my script has an error or infinite loop?
Runtime errors (syntax errors, nil-index errors, etc.) are caught and printed in red in the terminal panel. There is no execution timeout, so a genuine infinite loop will freeze the tab, reload the page to recover.