ENV to JSON Converter (and JSON to .env)
Turn .env files into JSON, nested JSON, TypeScript ProcessEnv typings, docker-compose environment lists or shell exports - and convert JSON back to .env. Handles quotes, comments, export prefixes, multi-line values and ${VAR} expansion exactly like dotenv.
.env ⇄ JSON Workspace
Paste a .env file to get JSON (or TypeScript, docker-compose, shell), or paste JSON to generate a .env file.
{
"DATABASE_URL": "postgres://app:[email protected]:5432/app?sslmode=require",
"DB_POOL_SIZE": 10,
"NODE_ENV": "production",
"APP_NAME": "Agenvix Tools",
"API_BASE": "https://api.example.com",
"STRIPE_SECRET_KEY": "sk_live_51Hxxxxxxxxxxxxxxxxxxxxxx",
"FEATURE_FLAGS": "converters,calculators",
"PORT": 3000,
"DEBUG": false,
"LOG_PATH": "${HOME}/logs/app.log",
"MAIL__HOST": "smtp.example.com",
"MAIL__PORT": 587
}| Key | Value (preview) | Type |
|---|---|---|
| DATABASE_URL | postgres://app:[email protected]:5432/app?sslmode=require | string |
| DB_POOL_SIZE | 10 | number |
| NODE_ENV | production | string |
| APP_NAME | Agenvix Tools | string |
| API_BASE | https://api.example.com | string |
| STRIPE_SECRET_KEY | sk••••••••••••xx | string |
| FEATURE_FLAGS | converters,calculators | string |
| PORT | 3000 | number |
| DEBUG | false | boolean |
| LOG_PATH | ${HOME}/logs/app.log | string |
| MAIL__HOST | smtp.example.com | string |
| MAIL__PORT | 587 | number |
Why Developers Use the Agenvix ENV ⇄ JSON Converter
Built on the real dotenv rules, with outputs you actually paste somewhere.
Faithful dotenv Parsing
Single quotes are literal, double quotes expand \n and \", unquoted values lose inline # comments, export prefixes are accepted and multi-line values work - the same rules as the dotenv library.
Nested Objects
Keys such as MAIL__HOST or database.port can be split into nested JSON, perfect for config loaders, Helm values and JSON Schema validation.
More Than JSON
Generate a TypeScript ProcessEnv declaration for autocomplete, a docker-compose environment block, or export statements for a shell session.
Secrets Never Leave
Keys that look like secrets are masked in the preview and nothing is transmitted - the converter is pure client-side JavaScript.
Simple as 1-2-3
How the Converter Works
From dotenv text to structured output in seconds.
Paste .env or JSON
Pick the direction. Comments, blank lines and export prefixes are understood automatically.
Choose Output Options
Flat or nested JSON, typed values (numbers, booleans), variable expansion and the output format you need.
Copy the Result
Copy or download the output and drop it into your config loader, CI secrets or compose file.
dotenv Syntax Rules Applied
How each construct is interpreted.
| Feature / Specification | Best Use Case | Engine / Output Standard | Privacy & Security | Performance Rating | Action |
|---|---|---|---|---|---|
| KEY=value | Plain values | Trimmed, inline # comment removed | String by default | Core | |
| KEY="a\nb" | Multi-line / escapes | \n \t \" \\ expanded | Can span lines | Core | |
| KEY='literal $x' | Keep $ and backslashes | No escapes, no expansion | Exactly as written | Core | |
| ${VAR} / ${VAR:-default} | Derived values | Expanded when enabled | dotenv-expand style | Optional | |
| export KEY=value | Shell-sourced files | Prefix ignored | Same as KEY=value | Core |
Environment Files, Explained Properly
1. What a .env file really is
A .env file is a list of KEY=value pairs read by libraries such as dotenv (Node), python-dotenv, Docker Compose and most hosting dashboards. It looks trivial, but the quoting rules differ subtly from a shell: values are strings, double quotes enable escape sequences and multi-line text, single quotes are literal, and anything after a space followed by # in an unquoted value is a comment. This converter applies those rules so the JSON you get matches what your runtime actually sees.
2. Flat vs nested JSON
Environment variables are flat, but configuration is hierarchical. Teams encode structure with a separator -MAIL__HOST (ASP.NET Core, many Node loaders) or mail.host - and the loader rebuilds the tree. Enable "Nested JSON" and choose the separator to reproduce that tree here.
"Typed values" converts 3000, true and null into JSON numbers, booleans and null. Leave it off when a consumer expects strings only (for example Kubernetes ConfigMaps and Compose files, where every value must be a string).
3. Typed process.env in TypeScript
The TypeScript output declares every key on NodeJS.ProcessEnv, giving you autocomplete and catching typos such as process.env.DATABSE_URL at compile time. Save it as env.d.ts and make sure it is included by your tsconfig. Values stay typed as string because that is what the runtime provides.
4. Handling secrets safely
Never commit real .env files; commit a .env.example with placeholder values instead. When you need to move secrets between formats - JSON for a secrets manager, compose for local development - use a local tool like this one rather than a service that stores submissions. The preview masks keys containing words like secret, token, password or key, and you can clear the workspace at any time.
Everything you need to know about .env and JSON
Parsing rules, nesting, types and security.
How do I convert a .env file to JSON?
Paste the file into the .env → JSON tab. Each KEY=value line becomes a JSON property. Choose flat or nested output, enable typed values if you want numbers and booleans, then copy or download the JSON.
Can I convert JSON back to a .env file?
Yes. Switch to JSON → .env. Nested objects are flattened with a separator (default __), keys are upper-cased and values that contain spaces or special characters are quoted.
How are quotes and comments handled?
The same way dotenv does it: lines starting with # are comments, an unquoted value stops at " #", double-quoted values expand \n and \" escapes and may span multiple lines, single-quoted values are taken literally.
What does variable expansion do?
With expansion enabled, ${VAR} and $VAR references are replaced by the value of VAR defined earlier in the file, and ${VAR:-default} falls back to default when VAR is empty - mirroring dotenv-expand.
Why are some values shown with dots?
Keys whose names contain secret, token, password, key, credential or similar words are masked in the preview table so you can share screenshots safely. The actual output contains the full values.
Does the tool upload my environment variables?
No. Parsing and conversion run entirely in your browser; nothing is sent to a server, logged or stored.
Related Developer Utilities
Discover companion utilities engineered for zero-log speed and browser-side execution.
YAML to JSON / JSON to YAML Converter
Convert YAML to JSON and JSON to YAML with validation, multi-document support, key sorting and indent control.
JSON Formatter & Validator
Prettify, format, repair syntax errors, and convert raw JSON data strings into trees.
Base64 Encoder & Decoder
Convert text, strings, or images into Base64 Data URIs with zero server logging.
Secure Password Generator
Create CSPRNG-backed secrets in batches with live entropy scoring.
UUID v4 Generator
Mint RFC 9562 random identifiers in bulk with version validation.
JWT Decoder & Inspector
Decode token headers, payloads and claims, then verify HMAC signatures locally.
More in Code & Data
Specialized utilities within the same technical domain
