.env ⇄ JSON
Convert a .env file into a JSON object and back again. Handles comments, quoted values and blank lines, so you can move configuration between formats without hand-editing.
About the .env ⇄ JSON
Environment variables configure apps without hard-coding secrets, and they live in .env files (KEY=value lines) or as JSON in many deployment platforms and CI systems. Moving between the two formats by hand is tedious and easy to get wrong with quoting and comments.
This converter parses KEY=value pairs — skipping comments and blank lines, respecting quotes — and emits clean JSON, or turns a flat JSON object back into .env lines. It runs entirely in your browser, so values that may be secret never leave your machine.
The .env convention was popularized by Ruby's dotenv gem and then ported to essentially every other ecosystem — Node's own dotenv package, Python's python-dotenv, PHP's phpdotenv — as a practical implementation of the twelve-factor app principle of storing configuration in the environment rather than in code. JSON shows up on the other side because that's the shape most deployment platforms (Docker Compose, Kubernetes ConfigMaps and Secrets, and most cloud providers' environment-variable APIs) actually expect or return.
A couple of common gotchas when moving between the two: a value containing an = sign (a database URL with a query string, for instance) needs everything after the first = treated as the value, not split again; and .env files are conventionally excluded from version control via .gitignore, since committing one accidentally publishes whatever secrets it holds — worth double-checking before you paste real production values into any tool, including this one.
How to use it
- 1Choose the direction (.env → JSON or JSON → .env).
- 2Paste your .env file or JSON object.
- 3Copy the converted output.
Features
- Convert both directions: .env → JSON and JSON → .env
- Ignores comments and blank lines
- Handles quoted values and = inside values
- Configurable JSON indentation
- One-click copy of the result
Frequently asked questions
How do I convert a .env file to JSON?
Select the .env → JSON direction, paste your KEY=value lines, and a JSON object with those keys appears, ready to copy.
Does it handle comments and quotes?
Yes. Lines starting with # and blank lines are ignored, and single- or double-quoted values are unquoted correctly.
Is my configuration private?
Yes. Conversion is entirely client-side, so secrets in your .env or JSON never get uploaded.
Does it support nested JSON?
Environment variables are flat key/value pairs, so JSON → .env expects a flat object. Nested values are stringified.
Where did the .env file format come from?
It was popularized by Ruby's dotenv gem and adopted across nearly every language (Node's dotenv, Python's python-dotenv, and others) as a simple way to follow the twelve-factor app principle of keeping configuration in the environment, not in code.
Should I commit a .env file to git?
No — .env files typically hold secrets (API keys, database credentials) and are conventionally excluded via .gitignore. Commit a .env.example with placeholder values instead, if your team wants to document which variables are needed.
What happens to a value that itself contains an = sign?
A correct .env parser treats everything after the first = as the value, so something like DATABASE_URL=postgres://user:pass@host/db?ssl=true is parsed as one value, not split again at the later =.