JSON to .env

Paste JSON and get .env at once, with errors pointed by line and column, then copy or download the result.

loading JSON to .env
About this tool

What are JSON and .env?

JSON is the text format of web APIs: objects in braces, lists in brackets, strings always in double quotes, and nothing else. A .env file holds environment variables as KEY=value lines, one per line; frameworks and Docker load it into the process environment at startup.

The usual case is a JSON config or secret that must become environment variables for Docker, a CI job or a twelve-factor app.

This page opens the data converter already set to JSON → .env. Paste the text, read the result as you type, then copy it or download it as a file. Errors show the line and the column. Nothing is sent anywhere: the conversion runs in your browser.

JSON vs .env

JSON.env
Extension.json.env
Media typeapplication/jsonnone (plain text)
Commentsnoyes (#)
Data typesstring, number, true/false, null, object, arraytext only
Nestingany depthnone: flat keys
Typical useAPIs, package.json, logssecrets and settings of apps, Docker, CI
SpecificationRFC 8259convention (no formal spec)

When to convert JSON to .env

  • Convert to .env when the values go into environment variables of an app or a container.
  • Keep JSON when another program or an API will read the data.

What changes in the conversion

  • Nested keys are joined with _ and upper-cased (database.url → DATABASE_URL), list items get their index (FEATURES_0), and values with spaces or symbols are quoted.

How to convert JSON to .env

  1. Paste your JSON in the input box (the page opens with an example you can replace).
  2. Read the .env on the right; it updates as you type. If something is wrong, the message says the line and column.
  3. Adjust the options if you need: indentation, sorted keys or type detection.
  4. Copy the result or download it as a .env file.

Example

This JSON input:

{
  "app": { "name": "orders", "port": 8080 },
  "database": { "url": "postgres://db:5432/orders", "pool": 10 },
  "features": ["pix", "boleto"]
}

becomes this .env, exactly as the converter writes it:

APP_NAME=orders
APP_PORT=8080
DATABASE_URL=postgres://db:5432/orders
DATABASE_POOL=10
FEATURES_0=pix
FEATURES_1=boleto

Frequently asked questions

Is my JSON sent to a server?

No. Conversion happens in your browser, so secrets in a config never leave your computer.

Does JSON to .env keep comments?

JSON has no comments, so there is nothing to lose. .env comments: yes (#).

What happens to nested data?

JSON nesting: any depth. .env nesting: none: flat keys. The tree is flattened into one key per value, as shown in the example.

Report a problem