Parses and loads environment variables from a .env file into the current process, or stringify data into a .env file format.
.env
Note: The key needs to match the pattern /^[a-zA-Z_][a-zA-Z0-9_]*$/.
// Automatically load environment variables from a `.env` fileimport "@std/dotenv/load"; Copy
// Automatically load environment variables from a `.env` fileimport "@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'"); Copy
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'");
Parses and loads environment variables from a
.envfile into the current process, or stringify data into a.envfile format.Note: The key needs to match the pattern /^[a-zA-Z_][a-zA-Z0-9_]*$/.