Hello World
println "Hello, World!"Tap Run to execute
main.groovy · output appears here
Press Run to execute
Output streams here as your program runs.
Groovy is a dynamic, optionally typed language for the Java Virtual Machine, created by James Strachan and first released in 2003, with later stewardship under the Apache Software Foundation. It offers a concise, expressive syntax that is largely compatible with Java, so most Java code is valid Groovy, while adding closures, native syntax for lists and maps, and powerful string handling.
Groovy supports both scripting and full object-oriented programming and integrates seamlessly with Java libraries and frameworks. It is widely used for build automation through Gradle, test specifications with Spock, and writing pipelines in Jenkins. Its metaprogramming features and domain-specific-language capabilities make it a flexible glue language across the Java ecosystem.
main.groovy 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.
println "Hello, World!"def name = System.in.newReader().readLine()
println "Hello, ${name}!"[1, 2, 3, 4].each { n ->
println n * n
}def add(a, b) {
a + b
}
println add(2, 3)def ages = [alice: 30, bob: 25]
ages.carol = 28
ages.each { name, age ->
println "$name is $age"
}def nums = [1, 2, 3, 4, 5]
println nums.collect { it * it }
println nums.findAll { it % 2 == 0 }
println nums.inject(0) { acc, n -> acc + n }class Point {
int x
int y
String toString() { "($x, $y)" }
}
def p = new Point(x: 3, y: 4)
println pdef divide(a, b) {
if (b == 0) throw new IllegalArgumentException("divide by zero")
a / b
}
try {
println divide(10, 0)
} catch (IllegalArgumentException e) {
println "Error: ${e.message}"
}def r = (1..5)
println r.collect { it * it }
def words = ["hi", "there", "world"]
println words*.toUpperCase()
println words*.length()def name = null
println name ?: "default"
def user = [profile: [email: "[email protected]"]]
println user?.profile?.email
println user?.missing?.fieldThe 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
Groovy is one of 46 single-file compiler scratchpads. Each run submits only main.groovy; 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 Groovy source file.