Agenvix Enterprise Suite
DevOps Converter

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.

How It Works
dotenv-Compatible Parser
Nested Keys (A__B)
TS, Compose & Shell Output
Secrets Stay Local
Agenvix Studio v2.0
.env parsed12 variables · 1 warning
Input:
DATABASE_URL, PORT, DEBUG, MAIL__HOST …
Output:
{ "PORT": 3000, "DEBUG": false, "mail": { … } }
Secrets:
Masked in preview, never uploaded
● Quotes & escapes respectedCopy as JSON / TS / YAML list
Quick Test Presets:Click to load
Quotes & escapes respected
100% Free

.env ⇄ JSON Workspace

Paste a .env file to get JSON (or TypeScript, docker-compose, shell), or paste JSON to generate a .env file.

JSON output
{
  "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
}
Variables
12
Secrets masked
1
Warnings
0
KeyValue (preview)Type
DATABASE_URLpostgres://app:[email protected]:5432/app?sslmode=requirestring
DB_POOL_SIZE10number
NODE_ENVproductionstring
APP_NAMEAgenvix Toolsstring
API_BASEhttps://api.example.comstring
STRIPE_SECRET_KEYsk••••••••••••xxstring
FEATURE_FLAGSconverters,calculatorsstring
PORT3000number
DEBUGfalseboolean
LOG_PATH${HOME}/logs/app.logstring
MAIL__HOSTsmtp.example.comstring
MAIL__PORT587number

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.

01

Paste .env or JSON

Pick the direction. Comments, blank lines and export prefixes are understood automatically.

02

Choose Output Options

Flat or nested JSON, typed values (numbers, booleans), variable expansion and the output format you need.

03

Copy the Result

Copy or download the output and drop it into your config loader, CI secrets or compose file.

Syntax Reference

dotenv Syntax Rules Applied

How each construct is interpreted.

Feature / SpecificationBest Use CaseEngine / Output StandardPrivacy & SecurityPerformance RatingAction
KEY=valuePlain valuesTrimmed, inline # comment removedString by defaultCore
KEY="a\nb"Multi-line / escapes\n \t \" \\ expandedCan span linesCore
KEY='literal $x'Keep $ and backslashesNo escapes, no expansionExactly as writtenCore
${VAR} / ${VAR:-default}Derived valuesExpanded when enableddotenv-expand styleOptional
export KEY=valueShell-sourced filesPrefix ignoredSame as KEY=valueCore
Comprehensive Guide

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.

Frequently Asked Questions

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.