Skip to main content
Yoryantra
← Back to Tools

JSON to ENV Converter

Flatten JSON configuration into environment assignments with explicit array, null, and quoting choices.

The root must be a JSON object. Duplicate member names and numbers that JavaScript would round are rejected before conversion.

How JSON should become ENV lines

ENV output

Generated environment-variable assignments will appear here.
Conversion runs in this browser component. Secrets remain visible in the input, generated output, browser memory, and any clipboard copy you make.
Dotenv has no native nested-object, array, null, or numeric type. The selected flattening and serialization choices are conventions that your application must interpret consistently.

Dotenv can only carry environment-variable text

JSON has objects, arrays, booleans, numbers, strings, and null. Environment variables do not preserve those types: applications read their values as strings. Turning JSON into .env text therefore needs decisions about key names and serialization, not just a change of punctuation.

There is no single universal dotenv specification. Node.js documents one concrete format with variable-name rules, comments, quoted values, multiline quoted text, and optional export prefixes. It is a useful baseline when checking generated output: Node.js .env documentation.

Nested JSON needs a naming convention

With flattening enabled, database.host becomes DATABASE_HOST and api.baseUrl becomes API_BASE_URL. Camel-case boundaries and punctuation are normalized into underscores, and a leading digit is prefixed with an underscore so the result remains a valid variable name under the Node.js rules.

Normalization can make different JSON paths converge on the same ENV name. Those collisions are reported as errors rather than choosing a winner. If flattening is disabled, a nested object is serialized as JSON text inside one environment value instead.

Arrays have no native .env representation

JSON text is the least ambiguous option because the full array shape remains visible. Comma-separated output is easier for simple lists but becomes ambiguous when an element itself contains a comma. Indexed variables such as FEATURES_0 and FEATURES_1 are another convention and require matching application code.

Quoting preserves text; it does not create a data type

Auto mode leaves simple values unquoted and quotes values that would otherwise be empty, contain whitespace, include comment syntax, or contain quote characters. The formatter chooses a delimiter that is not present in the value. If both single and double quotes are present, current Node.js environment-file parsing also accepts a backtick delimiter; other dotenv parsers may not, so that case is flagged. Node documents that syntax in its --env-file documentation.

Never-quote mode refuses values that need quoting instead of emitting text likely to be truncated or reinterpreted. That is safer than silently turning a value such as "hello # team" into "hello" under a parser that treats # as a comment.

Null and empty string are different source values

An empty JSON string is always preserved as an empty ENV value. JSON null follows the selected policy: empty output, skipped variable, or literal text null. That literal is still the four-character string "null" when an application reads the environment; it does not remain a JSON null value.

Precision and duplicate names are checked before parsing

JavaScript JSON parsing can silently collapse duplicate object member names and can round numbers beyond its safe numeric range. The conversion stops before either change occurs. RFC 8259 notes that duplicate names are not interoperable because receivers handle them differently. See RFC 8259 for the JSON interoperability guidance.

Treat generated secret files like the source configuration

Converting a token or password to a different syntax does not reduce its sensitivity. Likely secret values are masked only in the preview; the actual ENV output remains complete. Keep generated files out of source control unless the values are intentionally non-secret, and be careful when copying them into tickets, terminals, or chat logs.