Lua 5.4 · wasm

Lua playground

Run Lua 5.4 on a WebAssembly VM in this tab, with print output and real runtime errors.

0 characters

First run downloads the VM (about 270 KB).

The virtual machine runs in this tab. Nothing is sent to a server, and no state survives a reload.

Short answer: write Lua, press Run. print output appears below the editor; if the chunk fails, the error names what went wrong and the output up to that point stays visible.

Why a real VM and not a translator

Translating Lua to JavaScript is a common shortcut, and it quietly changes semantics: integer division, string coercion, metatables and coroutines never line up exactly. This page runs the actual Lua interpreter, so a snippet that works here works in your editor.

The sandbox

Want to run SQL instead? The SQL playground executes statements on SQLite, also locally.

Lua questions

Which Lua version is this?

Lua 5.4, compiled to WebAssembly. It is a real interpreter, so metatables, coroutines, integer division, goto and the standard library behave the way they do locally — not a JavaScript re-implementation of Lua.

What if my code loops forever?

It runs in a Web Worker and is terminated after six seconds, so an endless loop stops instead of freezing the tab. The next run starts a fresh worker — nothing from the killed chunk survives.

Can I read files or use io?

No. The virtual machine has no filesystem, no network and no access to the page — it is a sandbox with only the Lua standard library. That is also why nothing you type can leak into the site.

Why did print output appear only after the run finished?

The chunk runs to completion before the panel updates, so output and error are shown together. A chunk that errors still shows everything printed before the failure, which is usually where the bug is.

Related tools