Hello, World
import std.stdio;
void main() {
writeln("Hello, World!");
}Tap Run to execute
main.d · output appears here
Press Run to execute
Output streams here as your program runs.
D is a compiled systems programming language that aims to combine the performance and low-level control of C and C++ with the productivity of modern, higher-level languages. It offers strong static typing, garbage collection (which you can opt out of), templates, compile-time function execution, and clean module-based organization. CompileBytes builds D programs with GDC, the GCC-based D compiler; the reported version 10.2.0 reflects the GCC toolchain it ships with.
D programs start at a main function and use a familiar C-like syntax, so C and C++ programmers feel at home quickly. Beyond the basics, D provides ranges, slices, contract programming, and powerful metaprogramming via templates and mixins. Its standard library, Phobos, covers algorithms, ranges, I/O, and more, making D suitable for everything from quick scripts to high-performance applications.
main.d 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.d imports answer from the sibling helper module.
module main;
import std.stdio;
import helper : answer;
void main() {
writeln(answer());
}
module helper;
int answer() {
return 42;
}
import std.stdio;
void main() {
writeln("Hello, World!");
}import std.stdio;
int square(int n) {
return n * n;
}
void main() {
writeln(square(7));
}import std.stdio;
void main() {
foreach (i; 1 .. 6) {
writeln(i, " squared is ", i * i);
}
}import std.stdio;
import std.algorithm;
import std.array;
void main() {
int[] nums = [1, 2, 3, 4, 5];
auto evens = nums.filter!(n => n % 2 == 0).array;
auto total = nums.sum;
writeln("evens: ", evens);
writeln("sum: ", total);
}import std.stdio;
struct Point {
int x;
int y;
int manhattan() {
import std.math : abs;
return abs(x) + abs(y);
}
}
void main() {
auto p = Point(3, -4);
writeln("distance: ", p.manhattan());
}import std.stdio;
void main() {
int[string] counts;
foreach (word; ["a", "b", "a", "c", "b", "a"]) {
counts[word]++;
}
foreach (key, value; counts) {
writeln(key, ": ", value);
}
}import std.stdio;
import std.string;
void main() {
write("Enter your name: ");
string name = readln().strip();
writeln("Hello, ", name, "!");
}import std.stdio;
interface Shape {
double area();
}
class Circle : Shape {
double r;
this(double r) { this.r = r; }
double area() { return 3.14159 * r * r; }
}
void main() {
Shape s = new Circle(2.0);
writeln("area: ", s.area());
}import std.stdio;
T maxOf(T)(T a, T b) {
return a > b ? a : b;
}
void main() {
writeln(maxOf(3, 9));
writeln(maxOf(2.5, 1.5));
}import std.stdio;
import std.algorithm;
void main() {
int[] nums = [1, 2, 3, 4, 5];
auto doubled = nums.map!(x => x * 2);
auto total = nums.reduce!((a, b) => a + b);
writeln(doubled);
writeln("total: ", total);
}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
D is one of 23 linked-project compilers. Run always starts main.d; selecting a helper tab changes what you edit, not the entry file.
main.d imports answer from the sibling helper module.
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 D tab and a README in one ZIP archive.