About this tool
Convert dotenv files to JSON and back, with optional type coercion and double-underscore nesting.
This tool converts a dotenv (.env) file into JSON and converts JSON back into .env lines, with two optional transforms: type coercion (unquoted true, false, null and numeric strings become real JSON types) and nesting on a delimiter (DB__HOST becomes db.host, the double-underscore convention used by ASP.NET Core configuration and nconf). Values that were quoted in the .env are always preserved as strings.
Open Env to JSON Converter on AltFTool — it loads instantly in your browser.
Paste or upload your source content.
Choose the target format or conversion mode.
Copy or download the converted result.
One tool converts .env → JSON and JSON → .env, sharing the same delimiter convention so output round-trips.
PORT=3000 becomes the number 3000, but VERSION="1.10" stays the string "1.10" because it was quoted.
Double-underscore splitting with explicit conflict errors when A=1 and A__B=2 both exist, instead of silent data loss.
Paste the .env and copy the JSON: each KEY=VALUE line becomes a JSON property, comments are dropped, and with coercion enabled unquoted true/false, null and numbers become native JSON types. Enable nesting to fold DB__HOST and DB__PORT into a {"DB": {"HOST": ..., "PORT": ...}} object.
Because environment variable names cannot portably contain dots or colons, ASP.NET Core adopted __ as the hierarchy separator (ConnectionStrings__Default maps to ConnectionStrings:Default), and Node loaders like nconf support the same separator. This tool uses __ by default and lets you change the delimiter.
No — at runtime every environment variable is a string; process.env.PORT is "3000", not 3000. Coercion here only shapes the JSON representation. To keep a numeric-looking value as a string through conversion, quote it in the .env (VERSION="1.10").
Yes — switch the direction to JSON → .env. Nested objects flatten with the delimiter, arrays flatten by index (ARR__0, ARR__1), keys are upper-cased with invalid characters replaced by underscores, and values that would be misread unquoted — like "42" or text containing # — are double-quoted.
Add the Env to JSON Converterwidget to your blog or website — free, responsive, no signup. Just keep the “Widget by AltFTool” credit link visible.
<iframe src="https://www.altftool.com/embed/widget/env-to-json-converter"
title="Env to JSON Converter — free AltFTool widget"
width="100%" height="640" style="border:0;border-radius:12px;overflow:hidden"
loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
<p style="font-size:12px;margin:4px 0 0">Widget by <a href="https://www.altftool.com/tools/all/env-to-json-converter?utm_source=embed&utm_medium=widget">AltFTool — free online tools</a></p>