Hello, World!
print("Hello, World!")Tap Run to execute
main.lua · output appears here
Press Run to execute
Output streams here as your program runs.
Lua is a lightweight, high-level scripting language created in 1993 by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes at PUC-Rio in Brazil. It is designed to be small, fast, portable, and easily embeddable, with a simple syntax, dynamic typing, automatic memory management, and powerful tables as its core data structure.
Lua is widely used as an embedded scripting language in games (such as those built with the LÖVE framework and Roblox), applications, and configuration systems. It also powers tools like Redis scripting and Neovim configuration. Its minimal footprint and clean C API make it a popular choice for extending software with scripting.
main.lua is the entry point for each run.
Use the Input panel to pipe standard input to your program when it needs data.
Run sends your code to a fresh hosted runtime and streams the result into the output panel.
Your draft stays in this browser, and Share creates a separate snapshot link.
print("Hello, World!")io.write("Enter your name: ")
local name = io.read()
print("Hello, " .. name .. "!")local fruits = {"apple", "banana", "cherry"}
for i, fruit in ipairs(fruits) do
print(i .. ": " .. fruit)
endlocal function factorial(n)
if n <= 1 then return 1 end
return n * factorial(n - 1)
end
print(factorial(5))local ages = {alice = 30, bob = 25}
ages.carol = 28
for name, age in pairs(ages) do
print(name .. " is " .. age)
endlocal function risky(x)
if x < 0 then error("negative not allowed") end
return math.sqrt(x)
end
local ok, result = pcall(risky, -1)
if ok then
print("Result: " .. result)
else
print("Error: " .. result)
endlocal s = "Hello, Lua"
print(#s) -- length
print(string.upper(s)) -- uppercase
print(s:sub(1, 5)) -- substring
print(string.format("%d items", 3))local nums = {5, 2, 8, 1, 9}
table.sort(nums)
for _, n in ipairs(nums) do
io.write(n .. " ")
end
print()local function make_counter()
local count = 0
return function()
count = count + 1
return count
end
end
local next = make_counter()
print(next())
print(next())
print(next())local Animal = {}
Animal.__index = Animal
function Animal.new(name)
return setmetatable({name = name}, Animal)
end
function Animal:speak()
return self.name .. " makes a sound"
end
local a = Animal.new("Rex")
print(a:speak())The editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.
Type or paste your code into the editor, then click Run (or press Ctrl/Cmd + Enter) to execute it.
Output streams into the console panel, including runtime errors, exit status, and execution time.
Nothing to install and no account to create — code runs in an isolated hosted runtime.
Language-aware autocomplete and IntelliSense suggestions where the editor has a matching language service
Syntax highlighting, with native compiler and runtime errors shown in the console
Bracket matching, auto-indentation, code folding, and a minimap
Multi-cursor editing plus find & replace (Ctrl/Cmd + F)
Full undo/redo history and copy to clipboard
Built on Monaco — the same editor that powers VS Code
Run on demand, or turn on Auto-run to execute on every change
Stop long-running or infinite programs at any time
A real console shows standard output, errors, exit status, and execution time
Pass standard input (stdin) to your program from the Input panel — one value per line
Switch between light and dark themes
Adjust font size and other editor settings
Toggle side-by-side or top/bottom layouts
Enter distraction-free fullscreen mode
Generate a shareable link to your exact code in one click — no login needed
Your work autosaves to your browser, so you can pick up where you left off
Copy the active file to your clipboard
Run code: Ctrl/Cmd + Enter
Find & replace: Ctrl/Cmd + F
Open the full shortcut list from the keyboard icon in the toolbar
Lua is one of 46 single-file compiler scratchpads. Each run submits only main.lua; local sibling-file imports are not enabled.
Linked-project languages (23): Node.js, TypeScript, Deno, Python, C, Go, Dart, Swift, Rust, Ruby, PHP, Java, Kotlin, C++, C#, Nim, Crystal, Haxe, Zig, Scala, D, Bun, Objective-C.
Single-file scratchpads (46): Matplotlib, NumPy, pandas, Haskell, Clojure, Perl, Lua, Tcl, jq, Raku, Elixir, Bash, Zsh, Nushell, R, Assembly (NASM), Julia, Octave, Groovy, PowerShell, Visual Basic .NET, Odin, Pascal, Lisp, Erlang, CoffeeScript, COBOL, BASIC, V, Racket, OCaml, Prolog, AWK, Emacs Lisp, Emojicode, Forth, F#, Fortran, Assembly (NASM64), Solidity, Mojo, Ada, WASM (WAT), Gleam, Shell Script (sh), Scheme.
Download file exports the active Lua source file.