Paste a .env file and get JSON or YAML instantly, or turn a JSON object into NAME=value lines. Quotes, export prefixes, comments, multi-line values and ${VAR} references are parsed the way dotenv reads them.
Last updated:
Your secrets stay on your device: parsing runs entirely in this tab and nothing is sent anywhere. Tip: Ctrl + Enter converts.
Advertisement
Advertisement
How to use the ENV to JSON Converter
Pick a mode: .env → JSON, .env → YAML, or JSON → .env.
Paste your file or drop it on the input. A sample .env is loaded to start.
Choose options such as type conversion, ${VAR} expansion and nesting, or key style and quoting for .env output.
Check the result; any syntax error is shown with its line and a Show in input button.
Copy or download the converted file.
.env syntax at a glance
.env line
Value read
PORT=3000
3000 (string, or number with type conversion)
export DB_HOST=localhost
localhost (export is ignored)
URL=https://x.io # note
https://x.io
TAG=v1#beta
v1#beta (no space before #)
PASS='a$b#c'
a$b#c (single quotes are literal)
MSG="Hi\nthere"
Hi, line break, there
URL="db://${HOST}:5432"
db://localhost:5432 with expansion
EMPTY=
empty string
Good practice for .env files
Never commit secrets: keep .env in .gitignore and share a .env.example with placeholder values instead.
Quote anything with spaces or #: unquoted values end at an inline comment, so NAME=Ada # admin reads as just Ada.
Use names in UPPER_SNAKE_CASE: letters, digits and underscores only, not starting with a digit, so every shell and platform accepts them.
Remember everything is text: your app receives "false", not a boolean, so parse values explicitly in code.
Working with other config formats? Try the INI to JSON converter or turn JSON into YAML with JSON to YAML.
Frequently asked questions
Which .env syntax is supported?
The parser follows the rules of the popular dotenv libraries: NAME=value lines, an optional export prefix, # comment lines, inline comments after unquoted values (a # preceded by a space), single quotes for literal text, double quotes with \n, \t, \" and \\ escapes, backticks, and values in quotes that span several lines.
Are values converted to numbers and booleans?
Not by default, because environment variables are always strings. Tick Convert numbers & true/false to turn unquoted values like 3000 or false into JSON numbers and booleans. Quoted values always stay strings.
What does Expand ${VAR} references do?
It replaces ${NAME} and $NAME with the value of a variable defined earlier in the same file, like dotenv-expand. ${NAME:-default} uses the default when NAME is unset or empty. Single-quoted values and \$ are never expanded. Variables from your real system environment are not used.
What does Nest keys on __ do?
Keys with a double underscore, such as REDIS__HOST and REDIS__PORT, become a nested object {"REDIS": {"HOST": …, "PORT": …}}. This is the convention ASP.NET Core and several config libraries use to map environment variables to nested settings.
How is JSON converted to a .env file?
Each top-level key becomes a variable. Nested objects are flattened by joining keys with the separator you choose (DB_HOST, DB__HOST or db.host), names are upper-cased if you like, arrays become comma lists, JSON text or numbered variables, and values with spaces, # or quotes are quoted so they read back unchanged.
What happens with duplicate variables?
As in dotenv, the last definition wins. The tool tells you how many duplicates it found so you can clean up the file.
Is it safe to paste secrets?
Yes. The conversion runs in JavaScript inside this page; nothing is uploaded or stored on a server. You can even disconnect from the internet after the page loads.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.