Prefix mode vs marker mode
| Prefix mode | Marker mode | |
|---|---|---|
| Input looks like | DEV_DB_URL=… and PROD_DB_URL=… | blocks under # === dev === |
| Key names in output | prefix removed | unchanged |
| Shared values | keys without a matching prefix | lines before the first marker |
| File names | from the prefix: DEV_ → .env.dev | from the marker: # === prod === → .env.prod |
Prefix mode suits files where every key was namespaced; marker mode suits files that were already organised in sections. To go the other way and combine files, use the ENV merger.
Naming the files for your framework
| Framework | File names it loads automatically |
|---|---|
| Next.js | .env.development, .env.production, .env.test (+ .local variants) |
| Vite | .env.[mode], e.g. .env.staging with vite build --mode staging |
| Node.js 20.6+ | any name: node --env-file=.env.staging app.js |
| Docker Compose | any name: env_file: .env.prod per service |
Use prefixes like DEVELOPMENT_ and PRODUCTION_ if you want Next.js-ready file names straight away. The guide how to use dotenv explains loading per framework.
After splitting
- Compare the new files with the ENV diff checker to confirm only the intended keys differ.
- Generate a committed template from one of them with the .env.example generator.
- Move production values into your host's secret settings and delete the local
.env.prod.