.env · generator · Stripe
Stripe .env Generator
Stripe ships three keys per environment — publishable, secret, and webhook signing. This generator produces a .env block with the right prefixes (sk_test_, pk_test_, whsec_) and comments so you don't accidentally mix test and live values.
.env for Stripe · 4 keys
STRIPE_SECRET_KEY=sk_test_ STRIPE_PUBLISHABLE_KEY=pk_test_ STRIPE_WEBHOOK_SECRET=whsec_ STRIPE_PRICE_ID_PRO=price_
Secrets regenerate on every page load. Want to combine stacks (e.g., Next.js + Stripe + Supabase)? Use the full generator.
How to use this .env in Stripe
- 1.Paste the block into your project's .env or .env.local.
- 2.Swap the test prefixes (sk_test_, pk_test_) for live (sk_live_, pk_live_) only in production.
- 3.Set STRIPE_WEBHOOK_SECRET to the value Stripe shows when you create the webhook endpoint — it's unique per endpoint.
- 4.Never prefix STRIPE_SECRET_KEY with NEXT_PUBLIC_ or VITE_ — it would ship to the browser.
Gotchas
- ⚠Webhook signing secrets are per-endpoint, not per-account. Each webhook URL gets its own whsec_.
- ⚠Rotating a secret key invalidates it immediately — coordinate with any long-running jobs first.
- ⚠Stripe's CLI uses a separate restricted key; add STRIPE_API_KEY for local forward runs if needed.
Common keys explained
STRIPE_SECRET_KEYServer-only. sk_test_ for dev, sk_live_ for prod.
STRIPE_PUBLISHABLE_KEYSafe to expose to the browser. Prefix with NEXT_PUBLIC_ or VITE_ if needed.
STRIPE_WEBHOOK_SECRETwhsec_... — unique per webhook endpoint. Used by stripe.webhooks.constructEvent().
STRIPE_PRICE_ID_PROprice_... — optional but convention for tying price IDs to env.
Related tools
Other stacks
Node.js .env
/env-generator/nodejs
Next.js .env
/env-generator/nextjs
Django .env
/env-generator/django
Ruby on Rails .env
/env-generator/rails
React (Vite) .env
/env-generator/react
Python (FastAPI / Flask) .env
/env-generator/python
Go .env
/env-generator/go
Docker Compose .env
/env-generator/docker
Kubernetes .env
/env-generator/kubernetes
Firebase .env
/env-generator/firebase
Supabase .env
/env-generator/supabase
OpenAI .env
/env-generator/openai
Laravel .env
/env-generator/laravel