Convert a .env file to JSON
Paste a .env file and get a JSON object — comments stripped, quotes handled — for config loaders, test fixtures, or tooling that expects JSON rather than KEY=value.
Open the tool, then paste the sample input below. Everything runs locally in your browser.
The problem
Some tools and tests want configuration as JSON, but it lives in a .env file as KEY=value lines with comments and quotes. Hand-converting is tedious and easy to get wrong around quoting. A converter turns the .env into a clean JSON object.
Sample input
# database
DB_HOST=localhost
DB_PORT=5432
DB_NAME="app_dev"
Expected output
{
"DB_HOST": "localhost",
"DB_PORT": "5432",
"DB_NAME": "app_dev"
}
The comment line is dropped, surrounding quotes around app_dev are removed, and values are emitted as strings (env values are always strings).
How to do it
- Paste the .env file contents.
- Convert it to JSON.
- Check that comments are dropped and quotes handled.
- Copy the JSON object.
- Load it into your config or test fixture.
Common mistakes
- Expecting numbers and booleans — env values are strings.
- Leaving surrounding quotes in the value.
- Multi-line values that are not quoted.
- Committing the .env or its JSON with real secrets in it.
- Duplicate keys where the last one silently wins.
Related tools
Related guides
FAQ
How do I convert a .env file to JSON?
Paste the .env contents and convert. Each KEY=value line becomes a JSON property; comments are dropped and surrounding quotes are removed.
Are values numbers or strings?
Environment values are always strings, so DB_PORT=5432 becomes the string "5432". Convert types in your application if you need a number.
Are comments and quotes handled?
Yes. Lines beginning with # are treated as comments and dropped, and quotes wrapping a value are removed.
Is it safe to convert a .env with secrets?
Conversion runs locally and nothing is uploaded, but scan for secrets first and never commit the result; treat any real key as sensitive.
Is my .env uploaded?
No. Conversion runs locally in your browser. Your file is not sent to a server.
.env to JSON conversion runs locally in your browser. Nothing is uploaded.
Convert and scan config, format JSON, work with YAML — plus every other utility.