How this tool fits your workflow
What this converts
A .env file is a flat list of KEY=value lines that most frameworks load into environment variables at startup. JSON is what configuration APIs, CI systems, and deployment tools usually expect. This tool moves between the two.
The common reasons to convert are migrating local configuration into a hosting provider that takes JSON, generating a .env for local development from a secrets manager export, or simply reading a large .env file more comfortably as structured data.
Worked example: a typical .env
Dotenv syntax has more edge cases than it first appears. Here is what each form produces:
- Paste your .env contents into the left pane with the .env → JSON direction selected.
- Read the JSON on the right. Every value is a string, because that is what dotenv actually stores.
- Convert the other way by switching direction and pasting a JSON object. Values containing spaces or special characters are automatically double-quoted.
| .env line | JSON key | JSON value |
|---|---|---|
| DATABASE_URL=postgres://localhost:5432/app | DATABASE_URL | "postgres://localhost:5432/app" |
| export API_KEY=abc123 | API_KEY | "abc123" |
| APP_NAME="My App" | APP_NAME | "My App" |
| DEBUG=false | DEBUG | "false" ← string, not boolean |
| PORT=3000 | PORT | "3000" ← string, not number |
| # Database settings | (ignored) | (comment) |
| TIMEOUT=30 # seconds | TIMEOUT | "30" ← inline comment stripped |
Everything is a string, and that matters
Environment variables have exactly one type: string. DEBUG=false becomes the string "false", and the string "false" is truthy in JavaScript, Python, and most other languages. This is the single most common configuration bug in this area.
If you are consuming the JSON output in code, coerce explicitly rather than relying on truthiness: compare against the string "true", or parse numbers with Number() and check for NaN. Do not write if (config.DEBUG) and expect DEBUG=false to disable anything.
Common mistakes
- Committing the .env file. It belongs in .gitignore. If you have already committed secrets, rotate them — removing the file from a later commit does not remove it from history.
- Expecting variable interpolation. Some dotenv loaders expand ${OTHER_VAR} inside values; this converter does not, and treats the text literally.
- Leaving spaces around the equals sign. KEY = value is not valid dotenv in most loaders — the spaces become part of the key and value.
- Using multi-line values without quoting. A value spanning several lines needs double quotes with \n escapes, otherwise only the first line is read.
- Assuming key order matters. It does not for environment variables, so do not rely on one variable being defined before another.
When not to use this
Related workflow
Nested configuration needs flattening before it fits dotenv at all. The JSON flattener turns nested objects into dot-notation keys, which map cleanly onto environment variable names.
To check the JSON output is valid before pasting it into a deployment config, the JSON formatter validates and pretty-prints it.
If your configuration includes API tokens, the JWT decoder reads token claims locally so you can check an expiry date without pasting the token into a third-party site.
Frequently asked questions
- Are my secrets uploaded anywhere?
- No. Parsing runs in your browser with JavaScript and nothing is transmitted. That said, treat any secret you paste into any browser tab with care — clear the field when you are done.
- Does it handle comments and export statements?
- Yes. Lines beginning with # are ignored, as is a leading "export " on a variable line. Inline comments after an unquoted value are stripped too.
- What happens to quoted values?
- Double-quoted values have their quotes removed and \n and \t escapes expanded. Single-quoted values are taken literally, so $VAR inside them is not treated as a reference.
- Can it convert nested JSON to .env?
- Only partially. Dotenv has no nesting, so a nested object or array is serialised to a JSON string as the value. If you need real flattening, run the document through the JSON flattener first.
- Are all values strings?
- In the .env direction, yes — dotenv has no types, so DEBUG=false becomes the string "false", not a boolean. This is the most common surprise when converting to JSON.