Hello, World!
print("Hello, World!")Tap Run to execute
main.swift · output appears here
Press Run to execute
Output streams here as your program runs.
Swift is a general-purpose, compiled programming language created by Apple and first released in 2014. Designed as a modern, safe successor to Objective-C, it combines high performance with concise, expressive syntax, strong type inference, optionals for null safety, and support for object-oriented, protocol-oriented, and functional styles.
Swift is the primary language for building apps across Apple platforms—iOS, macOS, watchOS, and tvOS. It is also open source and increasingly used for server-side development and cross-platform projects on Linux. Its emphasis on safety and speed makes it well suited for everything from mobile apps to systems-level code.
main.swift is the entry point. Add helper files from the explorer and import them into your project.
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.
Swift source tabs compile as one module, so main.swift can call the helper directly.
print(answer())
func answer() -> Int {
42
}
print("Hello, World!")print("Enter your name: ", terminator: "")
if let name = readLine() {
print("Hello, \(name)!")
}let fruits = ["apple", "banana", "cherry"]
for (i, fruit) in fruits.enumerated() {
print("\(i + 1): \(fruit)")
}func factorial(_ n: Int) -> Int {
return n <= 1 ? 1 : n * factorial(n - 1)
}
print(factorial(5))enum ParseError: Error { case invalid }
func parse(_ s: String) throws -> Int {
guard let n = Int(s) else { throw ParseError.invalid }
return n
}
do {
let n = try parse("abc")
print(n)
} catch {
print("Error: \(error)")
}var counts: [Character: Int] = [:]
for ch in "banana" {
counts[ch, default: 0] += 1
}
for (ch, n) in counts {
print("\(ch): \(n)")
}let nums = [3, 1, 4, 1, 5]
let result = nums.sorted().map { $0 * 2 }
print(result)
print("Sum: \(nums.reduce(0, +))")struct Person {
let name: String
let age: Int
func describe() -> String {
return "\(name) (\(age))"
}
}
let p = Person(name: "Ada", age: 36)
print(p.describe())enum Shape {
case circle(Double)
case square(Double)
}
func area(_ s: Shape) -> Double {
switch s {
case .circle(let r): return 3.14159 * r * r
case .square(let side): return side * side
}
}
print(area(.square(3)))protocol Greet {
func hello() -> String
}
struct Dog: Greet {
func hello() -> String { return "Woof" }
}
let d = Dog()
print(d.hello())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
Swift is one of 23 linked-project compilers. Run always starts main.swift; selecting a helper tab changes what you edit, not the entry file.
Swift source tabs compile as one module, so main.swift can call the helper directly.
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. Their extra project files are not submitted to the runtime.
Download project exports every Swift tab and a README in one ZIP archive.