QCSunny Lab

.env ⇄ JSON Converter.env 与 JSON 互转工具

Output转换输出

Convert .env files to JSON and back: export prefixes, single- and double-quoted values, escaped newlines, inline comments and duplicate-key detection are all handled.

.env has no types — numbers and booleans stay strings in the JSON output, so the round trip back to .env is always lossless.

Frequently asked questions

How are inline comments handled?

An " #" after an unquoted value starts a comment (matching dotenv behaviour); inside quotes the # stays part of the value.

Can it convert nested JSON?

No — .env is a flat KEY=VALUE format; nested objects and arrays are rejected with the exact key named.

中文说明

.env 文件与 JSON 互转:export 前缀、单双引号值、转义换行、行内注释与重复键检测全部支持。

.env 没有类型——数字与布尔在 JSON 输出中保持字符串,因此转回 .env 永远无损。

常见问题

行内注释怎么处理?

未加引号的值后面出现 " #" 即视为注释(与 dotenv 行为一致);引号内的 # 保留为值的一部分。

能转换嵌套 JSON 吗?

不能——.env 是扁平的 KEY=VALUE 格式;嵌套对象与数组会被拒绝,并指出具体的键名。