.env to JSON Converter

Turn a .env file into JSON. Quotes, export lines, comments and multi-line values are understood.

Processed on your device. Files are not uploaded

How to convert a .env file to JSON

  1. Paste your .env file

    Paste or type it into the box, or press Try an example.

  2. Convert values

    Tick the box to turn numbers and true or false into real JSON values.

  3. Nest the names

    Optional. Names split on underscores become nested objects.

  4. Copy or download

    Use the JSON in your code.

Worked example

This is what .env to JSON Converter gives for its own sample values. Open the tool above and change anything to try your own.

.env

# database
DB_HOST=localhost
DB_PORT=5432
export DEBUG=true
GREETING="hello world"
Indentation
2 spaces
Convert numbers and true/false
Yes
Nest names split on underscores
No

JSON

{
  "DB_HOST": "localhost",
  "DB_PORT": 5432,
  "DEBUG": true,
  "GREETING": "hello world"
}

About .env to JSON Converter

Turn a .env file into JSON. Comments, export lines, single and double quotes and values that run over several lines are understood.

FAQs

Can it nest the names?

Yes. Turn on nesting and DB_HOST becomes db.host.

Are numbers converted?

Yes, by default. Turn the option off to keep every value as text.

Can I go the other way?

Use JSON to .env Converter.

Related tools