# mojo-dotenv ![]()
I’m excited to share **mojo-dotenv v0.2.0** - a modern `.env` file parser and loader for Mojo!
## What is it?
Load environment variables from `.env` files into your Mojo applications.
from dotenv import load_dotenv, dotenv_values, find_dotenv
from os import getenv
fn main() raises:
# Option 1: Load into environment
\_ = load_dotenv(".env")
print(getenv(“DATABASE_URL”))
# Option 2: Parse to Dict
var config = dotenv_values(“.env”)
print(config[“API_KEY”])
# Option 3: Auto-discover .env file
var env_path = find_dotenv()
\_ = load_dotenv(env_path)
## Features
**Parse .env files** - `dotenv_values()` returns `Dict[String, String]`
**Load into environment** - `load_dotenv()` sets environment variables
**Variable expansion** - `${VAR}` and `$VAR` syntax supported
**Multiline values** - Quoted strings can span multiple lines
**Escape sequences** - `\n`, `\t`, `\"`, `\\`, `\'` in quoted strings
**Auto-discovery** - `find_dotenv()` searches parent directories
**98%+ python-dotenv compatible** - Validated with comprehensive test suite
**Modern Mojo** - Built for Mojo 2025/2026 with latest syntax
**42 comprehensive tests** - Using Mojo’s TestSuite framework
**Multiple installation methods** - Git submodule, source copy, or .mojopkg
## Why?
- Separate configuration from code
- Different configs for dev/staging/prod
- Keep secrets out of version control
- Standard practice in Python, Node, Ruby ecosystems
- Now available in Mojo!
## Acknowledgments
This project builds on:
- **python-dotenv** - Reference implementation and compatibility target
- **mojoenv** by itsdevcoffee - Pioneer of .env in Mojo (2023), inspired this modern rewrite
**License**: MIT License
## Feedback Most Welcome!
This is a community project - PRs, issues, and feedback welcome!
- Issues: GitHub · Where software is built
Let me know if you use it in your projects! ![]()