Hello World
puts "Hello, World!"Tap Run to execute
main.cr · output appears here
Press Run to execute
Output streams here as your program runs.
Crystal is a statically typed, compiled language with a syntax heavily inspired by Ruby, created by Ary Borenszweig, Juan Wajnerman, and Brian Cardiff, with development beginning around 2011 and version 1.0 released in 2021. It aims to be as elegant and readable as Ruby while delivering the speed and efficiency of a compiled language built on LLVM.
Crystal uses powerful global type inference, so code often reads like a dynamic language despite being fully typed and checked at compile time. It supports object-oriented programming, generics, macros for metaprogramming, and lightweight fibers for concurrency. Crystal is used for web services, command-line tools, and performance-sensitive applications where developer happiness and runtime speed both matter.
main.cr 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.
main.cr requires helper.cr relative to the project directory.
require "./helper"
puts Helper.answer
module Helper
def self.answer : Int32
42
end
end
puts "Hello, World!"name = gets.try(&.chomp) || ""
puts "Hello, #{name}!"[1, 2, 3, 4].each do |n|
puts n * n
enddef add(a : Int32, b : Int32) : Int32
a + b
end
puts add(2, 3)ages = {"alice" => 30, "bob" => 25}
ages["carol"] = 28
ages.each do |name, age|
puts "#{name} is #{age}"
endclass Point
getter x : Int32
getter y : Int32
def initialize(@x : Int32, @y : Int32)
end
def to_s(io)
io << "(#{@x}, #{@y})"
end
end
puts Point.new(3, 4)nums = [1, 2, 3, 4, 5]
puts nums.map { |x| x * x }
puts nums.select { |x| x.even? }
puts nums.reduce(0) { |acc, x| acc + x }def divide(a : Int32, b : Int32) : Int32
raise ArgumentError.new("divide by zero") if b == 0
a // b
end
begin
puts divide(10, 0)
rescue ex : ArgumentError
puts "Error: #{ex.message}"
endenum Color
Red
Green
Blue
end
struct Pixel
getter color : Color
def initialize(@color : Color)
end
end
p = Pixel.new(Color::Green)
puts p.colordef find(arr : Array(Int32), target : Int32) : Int32?
arr.each_with_index do |v, i|
return i if v == target
end
nil
end
result = find([10, 20, 30], 20)
if result
puts "Found at index #{result}"
else
puts "Not found"
endThe 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
Crystal is one of 23 linked-project compilers. Run always starts main.cr; selecting a helper tab changes what you edit, not the entry file.
main.cr requires helper.cr relative to the project directory.
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 Crystal tab and a README in one ZIP archive.