DevOps

JSON to .env Converter

Convert a JSON configuration object into .env format, with flattening, quoting and naming conventions handled correctly.

Last reviewed by the Radiatus Cloud team

Want this automated for your stack?

We build CI/CD, Kubernetes & IaC pipelines that scale.

Talk to an engineer

Nested structures have to be flattened

Environment variables are a flat list of string pairs. A nested JSON object has no direct representation, so nesting must be flattened into compound keys, conventionally joined with underscores: a database object containing a host becomes DATABASE_HOST. Arrays are worse, becoming either indexed keys or a delimited string, and neither round-trips cleanly. If your configuration is deeply nested, environment variables may be the wrong destination for it.

Naming conventions matter

Convention is uppercase with underscores, and it is more than style: variable names are case-sensitive on Unix and case-insensitive on Windows, so mixed-case names behave differently across platforms. Names must not begin with a digit, and while many shells accept other characters, sticking to letters, digits and underscores avoids a class of quoting problems.

Quoting rules

Values containing spaces, a hash, or any shell metacharacter need quoting. A value with a hash left unquoted is truncated at that point by most parsers, which silently corrupts passwords and URLs containing a fragment. Values with newlines need double quotes and an escape sequence, and not every dotenv implementation supports multi-line values at all.

Everything becomes a string

JSON booleans and numbers lose their types: true becomes the four characters t-r-u-e, and the code reading it must interpret them. This trips people up because the string false is truthy in most languages, so a naive check on an environment variable set to false does the opposite of what was intended.

Handle the output like the secret it probably is

Configuration converted to .env usually contains credentials. The file belongs in .gitignore, should not be logged, and should not be pasted into a chat or ticket. Rotate anything that has been exposed rather than assuming nobody noticed.

Related tools

Frequently Asked Questions

How is nested JSON represented in .env?

By flattening into compound keys joined with underscores, so a database object containing host becomes DATABASE_HOST. Arrays become indexed keys or a delimited string, and neither round-trips cleanly.

Why are variable names uppercase?

Convention, but with a practical edge: names are case-sensitive on Unix and case-insensitive on Windows, so mixed-case names behave differently across platforms. Stick to letters, digits and underscores.

When do values need quoting?

Whenever they contain spaces, a hash or a shell metacharacter. An unquoted hash truncates the value at that point in most parsers, which silently corrupts passwords and URLs containing a fragment.

What happens to booleans and numbers?

They become strings. The JSON boolean true becomes the four characters t-r-u-e, and since the string false is truthy in most languages, a naive check does the opposite of what was intended.

Is the output safe to commit?

No. Converted configuration usually contains credentials, so the file belongs in .gitignore and should never be pasted into a ticket. Rotate anything that has been exposed.

Privacy & Security

All processing happens locally in your browser — nothing is uploaded.

Data: None
Client-side-Side
Active
v1.0

How to Use

Paste a JSON object; the equivalent .env variables are generated instantly.

Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.