.env to JSON Converter
Convert a documented .env subset to JSON locally, preserving strings and multiline values.
This tool processes its input contents in your browser instead of sending them to a processing service. Page, asset and fixed usage-measurement requests are described on the Privacy page.
Convert an explicit local .env subset into a JSON object whose values are all strings, with duplicate-name and syntax errors instead of silent overwrites.
How to use it
- 1Paste assignments or open a local UTF-8 file.
- 2Convert to JSON; quoted hashes and multiline strings follow the documented subset.
- 3Review values as strings and resolve any duplicate or unsupported syntax.
- 4Copy or download JSON without installing or executing it.
Example
- Input
- PORT=3000 ENABLED=false
- Output
- {"PORT":"3000","ENABLED":"false"}
No variable expansion, shell execution or automatic type conversion.
What happens to your data
Input stays in tab memory, never a URL or stored history. Downloads contain your configuration values. Optional analytics excludes source text, names, values and filenames.
Last updated November 2026
Convert environment-variable assignments into a JSON object without turning configuration strings into numbers or booleans. The converter runs locally and rejects duplicate names so an earlier value cannot quietly disappear. It handles an explicit Node-style subset with comments, optional export prefixes and multiline single- or double-quoted values.
The output is configuration text, not an installed environment. It does not contact providers, check credentials, expand variables or run commands.
How it works
Each accepted assignment becomes one own JSON property with a string value. PORT=3000 becomes "PORT": "3000", and ENABLED=false remains the string "false". Variable names use ASCII letters, digits and underscores and cannot start with a digit. An optional export prefix followed by whitespace is ignored. Names are case-sensitive, and duplicate names are rejected with a line number rather than overwritten. Keys such as constructor and __proto__ are retained as own data properties without changing any object prototype.
Outside quotes, leading and trailing ASCII spaces and tabs are removed and # begins a comment. Non-ASCII whitespace inside a value is retained as data. Single and double quotes preserve spaces and # and may span actual lines. In double quotes, literal backslash-n is converted to a newline; other backslash sequences remain literal. Single quotes preserve backslashes. Matching quote characters cannot be backslash-escaped in this subset: use the other quoting style where possible. Only whitespace or a # comment may follow a closing quote. Backtick quoting, malformed assignments and unclosed quotes are rejected. CRLF and CR line endings are normalized to LF, including quoted multiline text.
Dollar expressions such as $NAME, ${NAME} and $(command) remain literal text. No shell, interpolation, file include, JavaScript evaluation or process environment is used. There is no single universal dotenv dialect. This is a documented Node-style subset; some older Node versions and other dotenv or shell parsers differ. Review the converted JSON against the consumer you actually use, especially when quoting or backslashes matter.
Input is bounded to 512 KiB of valid UTF-8 and 5,000 variables. Output is also limited to 512 KiB. A BOM at the start is removed. Empty files, all-comment input, NUL bytes, duplicate assignments and output beyond the bound receive a clear error. Values remain strings even when they look like JSON, numbers or booleans.
Pasted configuration and local files stay in the current tab, with no upload, persistent history or input in the URL. Changing the input removes the old output and downloads. Copy and JSON download contain the supplied values, so keep exports private when the configuration is sensitive. Optional analytics records fixed action labels only, never configuration text, names, values or filenames.
Worked example: Types remain configuration strings
- Input
- PORT=3000 ENABLED=false LABEL="Hello # world"
- Result
- {"PORT":"3000","ENABLED":"false","LABEL":"Hello # world"}
The hash is protected by quotes. Neither numeric-looking nor boolean-looking text is coerced.
Common use cases
- Prepare a JSON configuration object from a local .env file while preserving string types.
- Review duplicated variable names instead of silently selecting the last assignment.
- Keep quoted multiline text, hashes and spaces intact under an explicit parsing subset.
- Convert synthetic configuration examples without running a shell or contacting services.
Frequently asked questions
Will false or 3000 become a JSON boolean or number?+
No. Environment values are strings. The output is "false" or "3000" so conversion does not silently change the data type.
Does it expand ${NAME} or execute $(command)?+
No. Those expressions are literal text. The tool does not access a shell, process environment or interpolation engine.
What happens when the same variable appears twice?+
The input is rejected with a line number. Resolve the duplicate explicitly before conversion; no earlier value is silently overwritten.
Is it compatible with every dotenv library?+
No. It implements the supported Node-style subset described on the page. Backtick quoting, escaped matching quotes and permissive trailing text are outside the subset. Check your target parser when exact dialect compatibility matters.
Can it verify API keys or install these variables?+
No. It converts local text into JSON. It does not call a service, validate credentials or modify your application environment.
Standards and limitations
Related tools
JSON Schema Generator
Generate a draft 2020-12 schema from JSON examples and check their observed types locally.
JSON Formatter & Validator
Format, validate, and minify JSON with exact line errors, a searchable tree, and private processing.
JSON String Escape
Escape text to one JSON string or strictly decode it, preserving embedded text and numeric IDs.
YAML ⇄ JSON Converter
Convert one YAML document to JSON or back with safe JSON-compatible types, indentation and downloads.