elefcode

.env ↔ JSON Converter

Convert environment files to JSON and back.

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. Comments are skipped, quoted values are unquoted correctly, export prefixes are removed, and escaped newlines inside double quotes are preserved.

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, so no values leave your device.

Related tools