elefcode

.env ↔ JSON Converter

Convert .env files to JSON, shell, Docker or Kubernetes formats and back. Nothing you paste is saved.

Advertisement

Guide

About the .env ↔ JSON Converter

A .env file stores configuration as simple KEY=value lines — database URLs, API keys, feature flags — that your app loads as environment variables. Sometimes you need those same values as JSON instead: to paste into a secrets manager, a CI configuration, a cloud console, or a JSON-based config file. This tool converts a .env file into a JSON object and back again.

It understands the quirks of dotenv syntax — comments, quoted values, export prefixes, and escaped newlines — so the conversion is faithful in both directions. Everything runs locally, which matters because env files often hold secrets.

What it handles

  • Comment lines starting with # are ignored.
  • An export prefix on a line is stripped.
  • Single- and double-quoted values are unquoted, with escaped newlines handled in double quotes.
  • Going the other way, values that contain spaces or special characters are automatically quoted.

Keep your secrets safe

Because .env files typically contain credentials, this conversion happens entirely in your browser — nothing is uploaded. As a general practice, keep .env files out of version control (add them to .gitignore) and never commit real secrets to a repository.

How to use it

  1. 1Choose the direction: .env → JSON or JSON → .env.
  2. 2Paste your .env file or JSON object into the input.
  3. 3Copy the converted output from the other pane.
  4. 4Use it in your secrets manager, CI config, or app configuration.

Frequently asked questions

What is a .env file?

A plain-text file of KEY=value pairs that stores configuration and secrets for an application. Tools like dotenv load these into environment variables at runtime.

Why convert .env to JSON?

Many platforms — secrets managers, CI systems, cloud consoles — accept or export configuration as JSON. Converting lets you move values between a local .env file and those systems.

Does it handle quoted values and comments?

Yes. Comment lines and inline comments (PORT=3000 # note) are skipped, export prefixes removed, single quotes kept literal, double-quoted escapes such as \n decoded, and quoted values may span several lines — as PEM keys and certificates do.

What does Expand ${VAR} do?

It replaces references like ${DB_USER} or ${PORT:-3000} with the values defined in the same file, the way dotenv-expand and Docker Compose do. Single-quoted values are left alone.

How do I make a .env.example?

Choose .env.example as the output. Every key is listed with an empty value and its comment, so you can commit it without leaking secrets.

Will values be quoted when converting back to .env?

Values containing spaces, special characters, or newlines are automatically wrapped in quotes so the resulting .env file parses correctly.

Is it safe to paste secrets here?

The conversion runs entirely in your browser and nothing is transmitted. Unlike most tools on this site, this one also never saves your input or puts it in a share link. Use Hide values when sharing your screen.

Learn more

Related tools