.env to JSON converter

Paste a .env file to get a JSON object of variables and values, handy for documentation or moving settings to a cloud service.

Loading the tool…

Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.

How to use it

  1. Enter .env text, turn numbers and true/false into typed values and indentation.
  2. The result appears straight away and updates as you edit.
  3. Copy the result, or copy a link that keeps the same values to share it.

How it is calculated

Blank lines and lines starting with # are skipped, and each NAME=value line is read with an optional export. Unquoted values are trimmed and a comment starts at # after a space. Inside double quotes \n, \t, \" and \\ are decoded; single quotes are taken literally. For a repeated name the last value wins.

Example

Inputs: Turn numbers and true/false into typed values = no, Indentation = 2 spaces. Result: JSON: { "APP_NAME": "ToolSahla", "APP_ENV": "production", "PORT": "3000", "DEBUG": "false", "DATABASE_URL": "postgres://user:pass@localhost:5432/app", "GREETING": "أهلا وسهلا" }; Variables: 6; Repeated variables: None.

# Application
APP_NAME="ToolSahla"
APP_ENV=production
PORT=3000
DEBUG=false
DATABASE_URL=postgres://user:pass@localhost:5432/app
GREETING='أهلا وسهلا'
{
  "APP_NAME": "ToolSahla",
  "APP_ENV": "production",
  "PORT": "3000",
  "DEBUG": "false",
  "DATABASE_URL": "postgres://user:pass@localhost:5432/app",
  "GREETING": "أهلا وسهلا"
}

Limits and caveats

  • References such as ${VAR} are not expanded; they stay as text.
  • .env rules differ slightly between tools; comment handling follows Docker Compose.

Questions about this tool

Why did #fff stay whole?

A # starts a comment only after a space, so HEX colors and similar values stay intact.

Do numbers stay as text?

Yes by default, since environment variables are text. Turn on typing to convert 3000 and true.

What if a variable repeats?

The last value wins, as in most tools, and the repeated names are listed in the result.