.env to JSON Converter
Example
Input:
DB_HOST=localhost # comment PORT=5432
Output:
{
"DB_HOST": "localhost",
"PORT": "5432"
}About this converter
The reverse trip: .env files drifting into documentation, audits and migrations are far easier to read as JSON. The parser follows the dotenv mainstream — KEY=value per line, optional export prefix, # comments (only at line start; a # inside an unquoted value is data to some parsers and a comment to others, so this parser keeps the dotenv behavior of treating full-line comments only when they start the line, and inline comments after whitespace are stripped), single/double quotes unwrapped. All values stay strings, truthfully: .env never had types, and inventing them here would corrupt secrets that happen to look like numbers (a PIN of 0123 must not become 123).
Frequently Asked Questions
Why is PORT a string, not a number?
Because .env values are always strings; converting "0123" to 123 would corrupt data. Type at the application layer.
Does it expand $VARIABLES inside values?
No — expansion is shell/dotenv runtime behavior with security implications; this parser shows you the literal file contents.