What is a .env file?
A .env file (dotenv file) stores configuration as KEY=VALUE pairs, one per line. It is the standard way to keep secrets and settings out of source code — database passwords, API keys, feature flags — following the twelve-factor app practice of storing config in the environment. Node.js, Python, Docker and most frameworks load these files at startup.
Why convert .env to JSON?
- CI/CD pipelines — many deployment systems (GitHub Actions secrets, cloud run configs) accept JSON more readily than dotenv format.
- Docker & Kubernetes — ConfigMaps and container env definitions are JSON/YAML; converting first avoids hand-editing.
- Sharing & debugging — a JSON object is easier to diff, validate and paste into API testers than raw dotenv text.
- Validation — converting surfaces syntax problems like duplicate keys or malformed lines before they break a deploy.
How to convert a .env file to JSON online
- Paste your
.envcontent into the converter above (or click Load sample to try it). - The JSON output updates live as you type — toggle Smart types if you want unquoted numbers and booleans converted to real JSON types.
- Click Copy JSON or Download .json to save it as
config.json.
Parsing rules the converter follows
- Blank lines and full-line
#comments are skipped (JSON has no comments). - A leading
exportprefix is stripped:export API_KEY=x→"API_KEY": "x". - Splits on the first
=only, so values may contain=(e.g. base64 tokens). - Matching surrounding single or double quotes are removed;
\n,\tescapes inside double quotes are honoured. - Unquoted values lose a trailing
# inline comment(a#inside quoted values is kept). - Double-quoted values may span multiple lines.
- Duplicate keys: the last value wins — the same convention dotenv loaders use — and you get a warning.
- By default every value stays a string (true dotenv semantics). Enable Smart types to turn unquoted
true/falseinto booleans and numeric values into numbers.
Honest privacy note
The conversion runs 100% in your browser — your content is never uploaded to any server. That said, .env files routinely hold production secrets, so as a habit avoid pasting live credentials on shared or public machines.
Frequently asked questions
How do I convert a .env file to JSON online for free?
Paste your dotenv content into the converter at the top of this page. The JSON output updates live as you type — then copy it or download it as config.json. No signup needed.
Are my .env secrets uploaded anywhere?
No. The entire conversion runs in your browser; nothing leaves your device. Still, avoid pasting live production credentials on shared or public machines as a general habit.
What happens to comments and blank lines?
They are dropped — JSON has no comment syntax. Only KEY=VALUE pairs appear in the output.
How are duplicate keys handled?
The last value wins, matching how dotenv loaders behave, and the converter shows you a warning naming the key.
Do quoted values keep their quotes?
No — matching surrounding quotes are removed, and = signs inside values are preserved. Escape sequences like \n inside double quotes are converted to real newlines.
Will PORT=3000 become a number in the JSON?
Only if you enable Smart types. By default every value stays a string, which is true dotenv semantics — most loaders hand you strings too.
Can I convert JSON back to .env format?
This widget is one-way (.env → JSON). For JSON reshaping, try the JSON to YAML or CSV to JSON tools below.
Try it now
Ready? Convert your .env file to JSON — free, instant, nothing uploaded.