ENV to JSON Converter
Convert a .env file into JSON, with correct handling of quoting, multi-line values, comments and exported variables.
Last reviewed by the Radiatus Cloud team
Output
Need this built for your product?
We design, build & host secure software & APIs.
There is no .env specification
The dotenv format grew out of a Ruby library and was copied into every other ecosystem with variations. Whether values can span lines, whether quotes are stripped, whether export prefixes are allowed, and how comments after a value are treated all differ between implementations. A converter has to pick a behaviour, and the safest assumption is the most common one: strip surrounding quotes, allow export, treat a hash as a comment only when it starts a line or follows whitespace.
Quoting changes meaning
An unquoted value has surrounding whitespace trimmed. A double-quoted value keeps whitespace and typically expands escape sequences such as newline. A single-quoted value keeps whitespace and is entirely literal. So the same characters produce three different values depending on the quotes, and converting without honouring that changes your configuration.
Everything is a string
Environment variables are strings by definition. Converting to JSON tempts a converter to infer types, turning the text true into a boolean and 8080 into a number. That is frequently wrong: a port read from an environment variable is normally expected as a string by the code reading it, and a value like 0644 loses its leading zero. Keeping strings matches how the file is actually consumed.
Comments and blank lines
Lines starting with a hash are comments and disappear. A hash later in a line is ambiguous: inside a quoted value it is literal, outside one it usually starts a comment. Getting that wrong truncates values containing a hash, which happens most often in passwords and URLs with fragments.
Never commit the output
A .env file holds credentials, which is why it belongs in .gitignore. Converting it to JSON does not change that, and a config.json full of secrets committed to a repository is a routine and serious leak. Convert for inspection or transformation, then handle the result with the same care as the original.
Related tools
- JSON Formatter — Format and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
- JSON Validator — Validate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
- Regex Tester — Test regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.
- HTML Minifier — Minify HTML by removing comments and redundant whitespace, without breaking inline elements or pre blocks. Runs entirely in your browser.
Frequently Asked Questions
Is there a standard .env format?
No. It grew from a Ruby library and was copied with variations, so multi-line support, quote stripping, export prefixes and inline comment handling all differ between implementations.
Do quotes around a value matter?
Yes, considerably. Unquoted values are whitespace-trimmed, double-quoted values keep whitespace and expand escapes like newline, and single-quoted values are entirely literal. Same characters, three different results.
Should values be converted to numbers and booleans?
Usually not. Environment variables are strings by definition, and code reading a port normally expects a string. Type inference also destroys values like 0644 by stripping the leading zero.
How are inline comments handled?
A hash starting a line is always a comment. A hash later in a line is ambiguous: literal inside quotes, a comment outside. Getting it wrong truncates passwords and URLs containing a fragment.
Is it safe to commit the JSON output?
No. A .env file holds credentials and belongs in .gitignore. Converting it to JSON does not change that, and committing a config file full of secrets is a routine and serious leak.
Privacy & Security
Converted locally in your browser. No data is sent to any server.
How to Use
Paste .env content to convert into JSON.
Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.
Related Tools
JSON Formatter
DeveloperFormat and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
JSON Validator
DeveloperValidate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
Regex Tester
DeveloperTest regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.