ENV to JSON Converter — Free Online

.env to JSON Converter

Transform any standard .env file into a nested JSON object. UPPER_CASE keys with underscores like APP_DATABASE_URL become nested objects — { "app": { "database": { "url": "..." } } }. Numbered keys (APP_SERVERS_0, APP_SERVERS_1) become JSON arrays, so JSON to .env and back round-trips. export prefixes, inline comments and multi-line quoted values are supported; single quotes are literal and double quotes expand \n and \t. If a name is both a value and a prefix (APP=1 and APP_NAME=x), app_name is kept as a flat key instead of being lost.

Use Cases

  • Environment Configuration — Convert .env files to structured JSON for programmatic use
  • CI/CD Pipelines — Transform environment variables into JSON for deployment configs
  • Container Orchestration — Bridge Docker/Cloud Run env vars with JSON-based tooling
  • Migration — Migrate from flat env variables to structured config files

Example

Input:

APP_NAME=MyApp
APP_VERSION=1.0.0
APP_SERVERS_0=192.168.1.1
APP_SERVERS_1=192.168.1.2
APP_DATABASE_URL=jdbc:postgresql://localhost:5432/mydb
APP_DATABASE_POOL_SIZE=10

Output:

{
  "app": {
    "name": "MyApp",
    "version": "1.0.0",
    "servers": ["192.168.1.1", "192.168.1.2"],
    "database": {
      "url": "jdbc:postgresql://localhost:5432/mydb",
      "pool": {
        "size": "10"
      }
    }
  }
}

Edge cases and how they are handled

  • Comments and blank lines are skipped. Lines starting with # are ignored.
  • Lines without = are skipped with a warning (shown in a toast, with the line number), so a stray word does not break the conversion.
  • Values stay strings. APP_PORT=8080 produces "8080", not the number 8080 — cast it in your application if you need a number.
  • Matching quotes are stripped. A value wrapped in "…" or '…' loses the outer quotes; escapes such as \n and \t inside are expanded.
  • Only the first = splits the line, so values that contain = (base64 padding, URLs with query strings) stay intact.
  • Duplicate keys: the last one wins.

FAQ

Is my .env file uploaded anywhere? No. The conversion runs entirely in your browser, which matters because .env files usually hold secrets.

Why did my key change case? Keys are lower-cased and underscores are treated as nesting separators, so flat variable names become a nested object. Use the Bash Properties to JSON tool if you want the keys kept exactly as written.

Can I go the other way? Use JSON to ENV to flatten a JSON object back into variables.