jsontoolskit.org
JSON and JSON Schema utilities, in the browser
Say hi →

JSON to .env

nested JSON → dotenv KEY=value lines · updated 28 July 2026

Flatten a JSON object into .env lines. Nested keys are joined with a separator (__ by default, the convention .NET and Spring both use), names are uppercased, and values that contain spaces, quotes or newlines are quoted and escaped so the file parses correctly.

Paste input to start.

How to convert JSON to a .env file

  1. Paste your JSON configuration object.
  2. Pick the Nested key separator. __ is what ASP.NET Core and Spring Boot expect for nested config; plain _ is more readable but ambiguous if your keys already contain underscores.
  3. Leave uppercasing on — that is the environment-variable convention on every Unix system.
  4. Tick Prefix with export if you plan to source the file in a shell rather than load it with a dotenv library.
  5. Copy or download the .env. Remember to add it to .gitignore.

How values are made safe

A note on secrets

This runs entirely in your browser, so pasting a config file here does not transmit it anywhere. Even so: a .env file is usually the most sensitive file in a repository. Keep it out of version control, and prefer your platform's secret manager over a file for anything production.

Privacy

Nothing is uploaded. The conversion runs in this tab using your own browser's JavaScript engine — no server sees your data, and the page keeps working with the network disconnected.

FAQ

Why double underscore for nesting?

Because a single underscore is ambiguous — DB_HOST_NAME could be db.host.name or db.hostName. ASP.NET Core and Spring Boot both settled on __ to make the split unambiguous, and other frameworks have followed.

Can I get the JSON back?

Yes — .env → JSON reverses it, including splitting on the separator. Types are inferred on the way back, since env values are always strings.

Does it handle deeply nested config?

Yes, at the cost of long names. Beyond three or four levels, environment variables stop being a good transport — mount the JSON as a file instead.