1. Home
  2. Developer
  3. .env Converter

.env Converter

Convert .env, JSON, YAML and docker environment variables to each other.

For every format and option in one place, use Server Config Generators →

Runs in your browser · No upload
Result
{ "NODE_ENV": "production", "PORT": "3000", "DATABASE_HOST": "db", "DATABASE_PORT": "5432", "LOG_LEVEL": "info", "GREETING": "hello world" }
Avoid pasting production secrets (passwords, tokens, keys) here. For files you share, blank the values to make a .env.example.
Review the result before using it. Quoting and escaping rules differ per format and may not match what you intended.

Your input is converted in this browser and never sent to a server.

How to use

  1. Choose the input format (.env, JSON, YAML or docker run -e flags) and paste your content. A sample is pre-filled so you see a result right away.
  2. Choose the output format: .env, JSON, YAML, docker run -e flags, a docker --env-file file, compose environment (map or list) or shell export statements.
  3. Turn on blank values, sort, nest or type conversion if you need them.
  4. Copy the result or download it under a fitting file name (.env, env.json, docker-run.sh and so on). Pasting the result back as input also works, so round trips are possible.

Conversion example

Converting NODE_ENV=production, PORT=3000 and GREETING="hello world":

Output format Result
JSON {"NODE_ENV": "production", "PORT": "3000", "GREETING": "hello world"} (all values are strings)
YAML Values that look like numbers are quoted to stay strings, like PORT: "3000"
docker run A command with -e NODE_ENV=production -e PORT=3000 -e GREETING='hello world', one flag per line
compose map KEY: value under environment:
compose list - KEY=value under environment:
export export GREETING='hello world'

Rules per format

  • Reading .env: supports # comments, the export prefix, empty values, single quotes (literal), double quotes (\n and \" escapes) and multi-line double-quoted values. In an unquoted value, a # after whitespace starts a comment while a#b is kept. A repeated key keeps the last value and is reported.
  • Reading JSON and YAML: nested objects and arrays are flattened into single-level keys like DATABASE_HOST and TAGS_0. Characters not allowed in keys become _, and numbers, booleans and null become strings (3000, true, empty). A pasted compose environment: block or a - KEY=VALUE list is understood too.
  • Writing JSON and YAML: by default every value is written as a string. With type conversion, only values like true, false and 3000 become booleans or numbers, and values with a leading zero such as 007 stay strings. With nest, DB__HOST=h becomes {"DB": {"HOST": "h"}}, the same double-underscore convention used by .NET configuration.
  • docker –env-file: this format does not strip quotes and has no multi-line values. So KEY=value is written as is, and multi-line values are skipped with a notice. Choose it separately from the .env format.
  • compose: $ starts variable substitution in compose files, so a $ in a value is written as $$. For example cost $5 becomes cost $$5.
  • Shell quoting: docker run and export output wraps values in single quotes and writes a ' inside as '\'', so a value with spaces, $ or a semicolon is never run as a command. Keys that break shell variable naming (letters, digits, _) are skipped.

Blank values and secrets

  • Blank values empties every value so the result works as a .env.example. For files you commit, share this form instead of real values.
  • Avoid pasting production secrets (passwords, API keys, tokens) even here. This tool runs only in your browser, but screenshots and screen sharing can still expose them. Review the result before using it.
  • To use the converted .env with containers, build a compose file with a .env.example using the Docker Compose Generator and the image with the Dockerfile Generator. To run it as a host service, use EnvironmentFile from the systemd Service Generator. Check YAML structure with the JSON YAML Converter, compare two .env files with Text Diff and tidy JSON with the JSON Formatter.

Frequently asked questions

When do I need quotes in a .env file?

For values with spaces, # or $, quotes are the safe choice. Single quotes keep the content as is, while double quotes interpret escapes like \n. This tool adds single quotes only where needed when writing.

Is docker run –env-file different from compose env_file?

Yes. docker run --env-file does not strip quotes and keeps them in the value, while compose .env and env_file interpret quotes and variable substitution. Pick the output format that matches where it will be used.

Do numbers become strings in JSON?

Environment variables are strings by nature, so the default is "3000". If your app expects numbers, turn on type conversion.

How do I use nested JSON as environment variables?

Reading flattens it into keys like DATABASE_HOST. Turn on “Uppercase keys” to get uppercase names. To go back from DB__HOST to nested JSON, use “Nest”.

Is my input sent to a server?

No. The conversion happens in your browser only.

Your input is converted in this browser and never sent to a server.

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.