.env · transform

JSON to ENV

Turn JSON objects into valid .env files. Flattens nested keys automatically with configurable separators.

Be the first to rate
DATABASE_URL=postgres://user:pass@localhost:5432/db
PORT=3000
DEBUG=true
STRIPE_SECRET_KEY=sk_test_xxx
STRIPE_WEBHOOK=whsec_xxx

What it does

  • Converts any JSON object into a valid .env file
  • Flattens nested keys with configurable separator
  • Uppercases keys and sanitizes invalid characters
  • Copy or download the result
  • Works offline — 100% client-side

Privacy

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

client-side only

Usage examples

Case 1 · Flat JSON
{
  "DATABASE_URL": "postgres://...",
  "PORT": 3000
}
DATABASE_URL=postgres://...
PORT=3000
Case 2 · Nested → flattened
{
  "database": { "url": "postgres://..." },
  "auth": { "jwt_secret": "xyz" }
}
DATABASE_URL=postgres://...
AUTH_JWT_SECRET=xyz
Case 3 · Arrays get stringified
{
  "ALLOWED_ORIGINS": ["http://localhost:3000", "http://localhost:5173"]
}
ALLOWED_ORIGINS=["http://localhost:3000","http://localhost:5173"]

When to use this tool

  • Migrating from a JSON config file to a .env
  • Exporting GitHub/GitLab Secrets as JSON and converting to .env
  • Bootstrapping local setup from a Vercel/Netlify export
  • Converting Firebase functions:config:get output to a .env

Common mistakes

  • Expecting arrays to survive — JSON arrays become stringified since .env values are strings
  • Losing type information: booleans and numbers become strings after flattening
  • Trusting the generated key names — double-check the casing matches your app's expectations
  • Forgetting to git-ignore the generated .env

Convert JSON to .env

Paste a JSON object and get a .env file back. The json-to-env converter flattens nested keys automatically so { "db": { "url": "..." } } becomes DB_URL=.... Useful for migrating configs, generating env files from GitHub Secrets exports, or bootstrapping local setup.

Frequently asked questions

What happens to nested JSON objects?

Nested objects are flattened using __ as the default separator. So { "database": { "url": "..." } } becomes DATABASE__URL=.... You can configure the separator in the tool options.

Are JSON arrays supported?

Arrays are JSON-stringified as the value. ["a", "b"] becomes ["a","b"] as a string. Most dotenv parsers treat this as a string literal; parsing it back into an array is the responsibility of your application code.

Are key names uppercased automatically?

Yes. JSON keys are uppercased and invalid characters (spaces, hyphens, dots) are replaced with underscores to produce valid dotenv key names.

Can I round-trip back to JSON from the .env output?

Yes — use the ENV to JSON converter. Note that type information is lost: all values become strings in .env, so numbers and booleans will need to be re-coerced when converting back.

Related tools

Learn more

Compare

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.