YAML / JSON / TOML / .env Converter

ENV to JSON Converter: Convert .env Files to JSON

Convert .env files to JSON format instantly. Handles comments, quotes, multi-line values, export prefixes, and auto-types booleans and numbers.

100% client-side. Your data never leaves your browser.

Related Tools

The JSON Output

Converting the example .env file produces:

{
  "APP_NAME": "myapp",
  "APP_PORT": 3000,
  "APP_DEBUG": true,
  "DATABASE_HOST": "localhost",
  "DATABASE_PORT": 5432,
  "DATABASE_NAME": "myapp",
  "DATABASE_USER": "admin",
  "DATABASE_PASSWORD": "secret",
  "DARK_MODE": true,
  "MAX_CONNECTIONS": 100,
  "ALLOWED_ORIGINS": "https://example.com https://api.example.com",
  "API_KEY": "sk-abc123xyz789",
  "JWT_SECRET": "my-super-secret-key"
}

Notice how APP_PORT, DATABASE_PORT, and MAX_CONNECTIONS are converted to numbers, while APP_DEBUG and DARK_MODE become booleans. Comments are stripped automatically.

How .env Files Work

.env files use simple KEY=VALUE syntax with these conventions:

FeatureSyntaxExample
Basic valueKEY=valueAPP_NAME=myapp
Quoted valueKEY="value with spaces"GREETING="hello world"
Empty valueKEY=EMPTY_VAR=
Comment# text# This is a comment
Export prefixexport KEY=valueexport API_KEY=abc

The parser handles all these variations and normalizes them to clean key-value pairs.

Common .env Patterns

Docker Compose

# docker-compose.env
POSTGRES_USER=admin
POSTGRES_PASSWORD=secret
POSTGRES_DB=myapp
REDIS_URL=redis://cache:6379

Vercel / Netlify

# .env.local
DATABASE_URL=postgresql://user:pass@host/db
NEXT_PUBLIC_API_URL=https://api.example.com
API_SECRET=sk-secret-key

Node.js Application

# .env
NODE_ENV=production
PORT=3000
LOG_LEVEL=info
CORS_ORIGIN=https://example.com

Why Convert to JSON?

Cross-Platform Migration

Moving from a .env-based platform (Docker, Vercel) to a JSON-based system (Kubernetes ConfigMaps, AWS Parameter Store)? Convert first to validate the structure.

Configuration Validation

JSON is easier to validate programmatically. Convert your .env to JSON, then run it through a JSON schema validator to catch missing or malformed values.

Team Collaboration

JSON is more self-documenting for team members unfamiliar with a project’s environment setup. The type information (numbers vs strings) is explicit.

.env Gotchas

The Norway Problem (Same as YAML)

Unquoted values like NO, TRUE, FALSE may be interpreted as booleans by some parsers. Always quote values that should remain strings:

# Wrong - might be parsed as boolean
COUNTRY=NO

# Right - explicitly a string
COUNTRY="NO"

Multi-Line Values

Multi-line values must be wrapped in quotes:

RSA_KEY="-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA0Z3VS5JJcds3xfn/ygWyF...
-----END RSA PRIVATE KEY-----"

Variable References

Some .env parsers support ${VAR} syntax for variable references. This tool resolves references within the same file when possible.