What is the D file format?
.d files contain source code written in the D programming language, a systems-level language designed by Walter Bright at Digital Mars and first released in 2001. D combines C-like syntax with higher-level features including garbage collection, built-in unit testing, template metaprogramming, mixins, ranges, and Uniform Function Call Syntax (UFCS).
D source files are plain UTF-8 text. A typical .d file begins with an optional module declaration, followed by import statements, then declarations for functions, classes, structs, interfaces, or templates. D supports inline documentation comments using /// (line) or / */ (block) syntax. Three compilers target .d files: DMD (the reference compiler), GDC (GCC front-end), and LDC** (LLVM back-end), all implementing the current D2 specification maintained at dlang.org.
D1 (the original version) was deprecated around 2010 and is source-incompatible with D2, which has been the active standard since then. Interface files with the .di extension serve a role analogous to C headers, containing declarations without implementation bodies. Editors support .d files via plugins - for VS Code the code-d extension provides syntax highlighting, completion, and build integration.
Security & safety
RISK: LOWPlain text source code - no executable content in the .d file itself; it must be compiled to run. Safe to open in any text editor. Untrusted D source code must be compiled and reviewed before execution.
Format details
in a nutshell- Makefile dependency file - GNU make and compilers (gcc -MD) generate .d dependency files listing header dependencies; plain text, no relation to D language.
- ChemDraw chemical output - Rarely, some ChemDraw export formats use .d; entirely unrelated to the D programming language.
- Patch / diff fragment - Some diff/patch tools use .d for unified diff fragments on Unix systems.
Programs that open D files
Technical details
deep spec| Format type | Plain text source code (UTF-8) |
| Encoding | UTF-8; BOM optional; non-UTF-8 source triggers a compile error |
| MIME type | text/x-dsrc |
| Typical file size | 500 B - 200 KB per source module |
| Module declaration | Optional `module name;` statement at top of file |
| Compilers | DMD (reference/Digital Mars), GDC (GCC front-end), LDC (LLVM back-end) |
| Language versions | D1 (deprecated ~2010) and D2 (current); the two are source-incompatible |
| Unit testing | Built-in `unittest` blocks embeddable directly in source files |
| Documentation comments | `///` (line) and `/** */` (block) DDoc syntax, processed by DMD -D flag |
| Conditional compilation | `version()` and `debug` blocks within source |
| Platform | Windows, Linux, macOS, FreeBSD |
| Related file | .di (D interface file - declarations only, analogous to C headers) |
| Standard library | Phobos (imported via `import std.*`) |
| Released | 2001 (D 1.0 by Walter Bright / Digital Mars) |
| Latest version | D 2.109.x (2026); D spec at dlang.org |
| Open standard | Yes · royalty-free |
| Specification | dlang.org |
Community Q&A
asked by usersNo questions yet - be the first to ask about D files.