Online D Compiler
Compile and run D online with LDC 1.43, the LLVM-based D compiler. Write a program with a main function, press Run, and LDC builds it and starts it, with compiler errors shown by line if the build fails. Programs can read input with readln, and Phobos, D's standard library, is ready to import.
How to run D code online
- This page opens with D selected, so you can start typing straight away.
- Write your code in the editor, or open files from your computer: single files, or a whole project as a .zip.
- Press Run, or Ctrl+Enter. The output appears in the panel beside the editor, and when the program asks for input you type it there and press Enter.
- Share a copy with a link, or save your files to your computer.
LDC 1.43 on Online IDE
- Your program is compiled with LDC 1.43, the LLVM-based D compiler, and starts in main.
- readln() reads a line of input with its newline, so strip it before converting it with to!int from std.conv.
- Output shows as soon as it is written, so a prompt from write appears before readln waits.
- Phobos, D's standard library, is available, as are modules you import from other .d files beside your program, but dub packages are not.
Example: a D program that reads input
import std.stdio;
import std.algorithm : filter;
import std.conv : to, ConvException;
import std.range : iota;
import std.string : strip;
void main()
{
write("Enter a whole number: ");
int n;
try
n = readln().strip.to!int;
catch (ConvException)
n = 0;
if (n > 0)
writeln("Divisors of ", n, ": ", iota(1, n + 1).filter!(d => n % d == 0));
else
writeln("Please enter a whole number above zero.");
}
Features of this tool
- Simple and fastA clean, lightweight editor that opens instantly.
- Powered by AceThe Ace code editor, with syntax highlighting, autocompletion and bracket matching.
- Interactive programsType input into the terminal while your program runs.
- Several filesWork in tabs, open files or a .zip from your computer, and save the project back to disk.
- Made for learningHelpful for beginners to learn and practice programs.
- Light and dark themesPlus 39 editor themes, a choice of coding fonts, and Vim, Emacs or VS Code keys.
- Keep your outputCopy or download the program output in one click.
- Share by linkSave your code in the cloud and open it anywhere.
Frequently asked questions
Which D compiler does Online IDE use?
LDC 1.43, which pairs the reference D front end with LLVM to compile your program for Linux.
Can a D program read input?
Yes. readln() returns the next line, and readf reads formatted values. Type into the output panel while the program waits and press Enter.
Can my program have several modules?
Yes. Put each module in its own .d file beside main.d; the compiler finds the modules your program imports.
Can I use dub packages?
No. Programs cannot download packages. Phobos and druntime are available.
Contact us
For any feedback, queries or issues, please feel free to contact us or write to . We value your input and are committed to providing the best possible experience for our users.