On this page
@std/dotenv
Unstable
This @std package is experimental and its API may change without a major version bump.
Overview Jump to heading
Parses and loads environment variables from a .env file into the current
process, or stringify data into a .env file format.
Note: The key needs to match the pattern /^[a-zA-Z_][a-zA-Z0-9_]*$/.
// Automatically load environment variables from a `.env` file
import "@std/dotenv/load";
import { parse, stringify } from "@std/dotenv";
import { assertEquals } from "@std/assert";
assertEquals(parse("GREETING=hello world"), { GREETING: "hello world" });
assertEquals(stringify({ GREETING: "hello world" }), "GREETING='hello world'");
Add to your project Jump to heading
deno add jsr:@std/dotenv