{"id":26140759,"url":"https://github.com/andybarron/env","last_synced_at":"2026-04-30T08:39:09.444Z","repository":{"id":246634018,"uuid":"821709015","full_name":"andybarron/env","owner":"andybarron","description":"Zero-dependency environment variable parsing in Node, Deno, and Bun","archived":false,"fork":false,"pushed_at":"2024-07-04T21:31:17.000Z","size":57,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-07-05T16:27:37.659Z","etag":null,"topics":["bun","configuration","deno","environment-variables","nodejs","zero-dependency"],"latest_commit_sha":null,"homepage":"https://jsr.io/@andyb/env/doc","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit-0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andybarron.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-29T07:59:35.000Z","updated_at":"2024-07-04T21:31:20.000Z","dependencies_parsed_at":"2024-06-29T09:22:36.512Z","dependency_job_id":"d8490b24-3d49-44f0-beab-ea12cdde80bb","html_url":"https://github.com/andybarron/env","commit_stats":null,"previous_names":["andybarron/env"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andybarron%2Fenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andybarron%2Fenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andybarron%2Fenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andybarron%2Fenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andybarron","download_url":"https://codeload.github.com/andybarron/env/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242961722,"owners_count":20213316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","configuration","deno","environment-variables","nodejs","zero-dependency"],"created_at":"2025-03-11T02:57:15.313Z","updated_at":"2025-10-29T20:50:31.805Z","avatar_url":"https://github.com/andybarron.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [`@andyb/env`](https://github.com/andybarron/env)\n\n_Zero-dependency environment variable parsing in Node, Deno, and Bun_\n\n[Documentation](https://jsr.io/@andyb/env/doc) \u0026bull;\n[Source](https://github.com/andybarron/env)\n\n[![JSR Version](https://img.shields.io/jsr/v/%40andyb/env?style=flat\u0026logo=jsr\u0026color=%231e1f45)](https://jsr.io/@andyb/env)\n[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/andybarron/env/ci.yml?branch=main\u0026style=flat\u0026logo=github)](https://github.com/andybarron/env/actions?query=branch%3Amain)\n[![Codecov](https://img.shields.io/codecov/c/github/andybarron/env?style=flat\u0026logo=codecov)](https://app.codecov.io/github/andybarron/env)\n[![JSR Dependencies](https://img.shields.io/badge/dependencies-0-8A2BE2)](https://jsr.io/@andyb/env/dependencies)\n\n## Installation\n\n| Tool                         | Install command               |\n| ---------------------------- | ----------------------------- |\n| [Bun](https://bun.sh)        | `bunx jsr add @andyb/env`     |\n| [Deno](https://deno.com)     | `deno add @andyb/env`         |\n| [NPM](https://www.npmjs.com) | `npx jsr add @andyb/env`      |\n| [PNPM](https://pnpm.io)      | `pnpm dlx jsr add @andyb/env` |\n| [Yarn](https://yarnpkg.com)  | `yarn dlx jsr add @andyb/env` |\n\n## Quickstart\n\n```ts\nimport * as env from \"@andyb/env\";\n\n// parse() is compatible with process.env in Node and Deno.env in Deno.\n// On failure, the thrown error will report every variable that failed to parse.\nconst config = parse(process.env, {\n  // Specify expected type and environment variable name.\n  favoriteNumber: env.integer().variable(\"FAVORITE_NUMBER\"),\n  // Mark some environment variables as optional. They will only be parsed if present.\n  nickname: env.string().variable(\"NICKNAME\").optional(),\n  // Default values can be provided. This makes the variable optional as well.\n  lovesDeno: env.boolean().variable(\"LOVES_DENO\").default(true),\n  // If no variable is specified, the property name will be used.\n  TZ: env.string(),\n});\n\n// config will have its type inferred correctly:\ntype InferredType = {\n  favoriteNumber: number;\n  nickname: string | undefined;\n  lovesDeno: boolean;\n  TZ: string;\n};\n```\n\n## Custom parsers\n\n```ts\nimport * as env from \"@andyb/env\";\nimport ms from \"ms\";\n\n// To parse custom types, provide a description and a parser function.\nfunction duration() {\n  return env.custom(\n    'must be a duration e.g. \"10 seconds\"',\n    (value: string): number =\u003e ms(value),\n  );\n}\n\nconst config = parse(process.env, {\n  // Custom parsers have the same chainable configuration methods as the\n  // built-in parsers.\n  timeoutMs: duration().variable(\"TIMEOUT\").optional(),\n});\n\n// Type inference works for custom and async parsers as well:\ntype InferredType = {\n  timeoutMs: number;\n  healthCheck: number;\n};\n```\n\n## Built-in parser types\n\n```ts\nimport * as env from \"@andyb/env\";\n\nconst config = env.parse(process.env, {\n  BOOLEAN: env.boolean(), // only accepts \"true\" and \"false\"\n  INTEGER: env.integer(),\n  JSON: env.json(), // accepts any valid JSON value\n  NUMBER: env.number(),\n  PORT: env.port(), // accepts integers from 0 to 65545\n  STRING: env.string(),\n});\n\ntype InferredType = {\n  BOOLEAN: boolean;\n  INTEGER: number;\n  JSON: env.JsonValue;\n  NUMBER: number;\n  PORT: number;\n  STRING: string;\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandybarron%2Fenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandybarron%2Fenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandybarron%2Fenv/lists"}