.env converter
Convert a .env file to JSON, YAML, a Docker --env-file or a systemd EnvironmentFile, and back again. Each value is quoted the way the target format reads it, and values a format can't hold are listed, not silently changed.
Runs in your browser. Nothing you type is sent anywhere.
The tool is code on this page. It makes no network requests while you use it, stores nothing in cookies or local storage, and keeps working if you go offline after the page loads.
.env converter
Runs in your browser
Output: JSON
Paste a file on the left to see it converted.
Example values use Kiteline, a fictional company.
How to use it
- Choose the format you have and the one you need. The swap button turns the conversion around.
- Paste the file. The result updates as you type.
- Read the list under the result: it names every value that changed meaning or couldn't be written, such as a multi-line certificate going to a Docker --env-file.
- Copy the result. Comments and blank lines aren't carried over, only names and values.
The same without a browser
For simple files on your own machine. The Python version understands quotes; the jq versions assume plain KEY=VALUE lines.
python3 -c "import json, dotenv; print(json.dumps(dotenv.dotenv_values('.env'), indent=2))"jq -r 'to_entries[] | "\(.key)=\(.value)"' env.jsonHow the formats differ
The same variable is written differently in each format. These are the rules the converter follows, from each format's own documentation and source.
| Format | Quotes | Comments | Multi-line values | Expands $VAR |
|---|---|---|---|---|
| .env (dotenv) | Single, double and backticks | # at the start of a line, or after a space | Inside quotes | Depends on the loader |
| Docker --env-file | None: quotes become part of the value | # at the start of a line only | No | No |
| systemd EnvironmentFile | Single (literal) and double (shell escapes) | # or ; at the start of a line | Inside quotes | No |
| JSON | Every value is a string | None | As \n | No |
| YAML | Single and double | # after a space | As \n in double quotes | Docker Compose does, unless written $$ |
How Crunu handles this
Files stay in their own format
Crunu keeps env files, INI files like ~/.aws/credentials and flat YAML as they are, and shows their variables as a table. When a file has to go elsewhere, you can export an environment as one .env file, as an Ansible Vault file that opens with ansible-vault view, or as an offline copy that opens without the server. On a server, crunu pull can write an environment's variables to one file for systemd's EnvironmentFile=, with permissions 0600.
Read about export and offline copiesQuestions about this tool
Found a case the tool gets wrong? Write to support@crunu.com
Why are the quotes gone in the Docker file?
docker run --env-file takes everything after = literally, quotes included: KEY="x" gives the value "x" with the quote marks. So the converter writes values without quotes, and leaves out values that span lines, which the format can't hold.
Why are numbers and true quoted in the YAML?
So they stay strings. Unquoted, YAML reads 3000 as a number and true or yes as a boolean, and a tool that reads them may write them back in another form, such as True. Environment variables are always strings.
What happens to comments?
They're dropped. The converter carries names and values only, because comments can't be represented in JSON and mean different things in the other formats.
Can it read nested JSON or YAML?
No. Environment variables are a flat list, so nested objects and lists are reported and skipped rather than flattened under invented names.
Read more
Other free tools
- Secret key generatorRandom secrets in Base64, Base64URL, hex or letters and digits, from 128 to 512 bits, with a ready .env line.
- .env linterFinds lines that loaders read differently, values that run as commands when sourced, duplicates and values that look like real keys.
- Compare two .env filesShows which variables exist in only one file and which have different values, with values hidden until you ask.
- OIDC trust policy builderTrust policies and credentials for GitHub Actions, GitLab CI and Bitbucket Pipelines on AWS, Google Cloud and Azure, with the CI snippet.
- Offboarding checklist generatorPick the services someone could reach and get an ordered checklist of what to close and which keys to reissue, with links.
When the values need a home
Crunu is a vault for your team's environment variables and keys. Values are encrypted on your devices, so the server stores them only as ciphertext. Free during early access.