.env · workflow🔒 100% client-side — never leaves your browser

ENV Splitter: split one .env into per-environment files

Split a .env file by environment: this ENV splitter turns one combined file into .env.dev, .env.staging, .env.prod and so on, either by key prefix (DEV_DB_URL → DB_URL in .env.dev) or by comment markers like # === prod ===.

By Aliniyaz Mamat · last reviewed

Be the first to rate
.env.dev
3 keys
SHARED_API_VERSION=v2
DATABASE_URL=postgres://localhost/dev
LOG_LEVEL=debug
.env.prod
3 keys
SHARED_API_VERSION=v2
DATABASE_URL=postgres://prod.example.com/app
LOG_LEVEL=info
.env.test
2 keys
SHARED_API_VERSION=v2
DATABASE_URL=postgres://localhost/test

Key takeaways

  • ✓Prefix mode: keys starting with DEV_, STAGING_, PROD_ or TEST_ (configurable) go to their file with the prefix removed.
  • ✓Keys without a prefix are shared and copied into every file, but an environment-specific key always wins over a shared one with the same name.
  • ✓Marker mode: everything below # === name === goes into .env.name; lines before the first marker go into every file.
  • ✓Quotes are kept, so values with # or spaces stay intact in the split files.

What it does

  • ▸Split by key prefix with automatic prefix stripping
  • ▸Split by # === env === comment markers
  • ▸Shared keys copied to every file, specific keys win
  • ▸Configurable prefix list
  • ▸Copy or download each file, 100% client-side

Privacy

Runs 100% in your browser. Your .env never touches our servers.

client-side only

Usage examples

Case 1 · Prefix mode
DEV_DATABASE_URL=postgres://localhost/dev
PROD_DATABASE_URL=postgres://db.prod/app
LOG_FORMAT=json
# .env.dev
LOG_FORMAT=json
DATABASE_URL=postgres://localhost/dev

# .env.prod
LOG_FORMAT=json
DATABASE_URL=postgres://db.prod/app
Case 2 · Specific key beats shared key
LOG_LEVEL=info
DEV_LOG_LEVEL=debug
# .env.dev
LOG_LEVEL=debug
Case 3 · Marker mode
APP_NAME="Acme"
# === staging ===
API_URL=https://staging.acme.dev
# === prod ===
API_URL=https://api.acme.com
# .env.staging
APP_NAME="Acme"
API_URL=https://staging.acme.dev

# .env.prod
APP_NAME="Acme"
API_URL=https://api.acme.com

When to use this tool

  • →Breaking up a legacy file that holds every environment with DEV_/PROD_ prefixes
  • →Creating per-environment files for Next.js or Vite modes (.env.development, .env.production)
  • →Preparing separate values to paste into staging and production hosting dashboards
  • →Splitting a monorepo .env by service prefix (API_, WEB_, WORKER_)

Common mistakes

  • ⚠Prefixes that are part of real names: TEST_ also matches TEST_MODE_ENABLED, which you may want in every file
  • ⚠Leaving production secrets in the split files on a laptop. Paste them into your host and delete the local copy
  • ⚠Committing the generated .env.prod. Only .env.example belongs in git
  • ⚠Forgetting to update code that read the prefixed names (process.env.DEV_DB_URL) to the stripped name

Prefix mode vs marker mode

Prefix modeMarker mode
Input looks likeDEV_DB_URL=… and PROD_DB_URL=…blocks under # === dev ===
Key names in outputprefix removedunchanged
Shared valueskeys without a matching prefixlines before the first marker
File namesfrom the prefix: DEV_ → .env.devfrom 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

FrameworkFile 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 Composeany 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

  1. Compare the new files with the ENV diff checker to confirm only the intended keys differ.
  2. Generate a committed template from one of them with the .env.example generator.
  3. Move production values into your host's secret settings and delete the local .env.prod.

Frequently asked questions

How does prefix splitting work?

A key that starts with one of the listed prefixes goes to that environment's file with the prefix removed: DEV_DB_URL becomes DB_URL in .env.dev. Keys without a listed prefix are copied to every file.

What if a shared key and a prefixed key end up with the same name?

The environment-specific one wins. LOG_LEVEL=info plus DEV_LOG_LEVEL=debug gives LOG_LEVEL=debug in .env.dev, written once.

What are comment markers?

Comment lines like # === prod ===. Every line until the next marker goes to .env.prod. Lines before the first marker are shared by all files.

Can I use other prefixes than DEV, STAGING, PROD and TEST?

Yes. Edit the comma-separated prefix list, e.g. API_, WEB_, WORKER_ to split a monorepo file by service.

Is my .env uploaded?

No. Splitting runs in your browser.

Related tools

Learn more

coming soon

Get notified when env syncing launches

We're building a tiny tool to keep .env files in sync across teammates and environments. Leave your email — no spam, just a single launch ping.

We use your address only for this launch email. You can ask us to delete it at any time. Privacy policy