Skip to content

JSON to .env converter

Paste a JSON object. Each value becomes a NAME=value line.

Check the output before committing it. A .env file often holds secrets, and it belongs in .gitignore.

Ctrl+Enter or ⌘+Enter runs this tool immediately.

Nested keys
JSON object
.env

Waiting for input.

Parsing stays in this browser. Input is not uploaded or saved.

How to use this tool

  1. Paste a JSON object, such as a config file or a secrets manager export, or load the sample.
  2. Choose how nested keys are joined. A__B is what ASP.NET Core and many config libraries read as nesting. A_B is shorter.
  3. Copy the lines or download the .env file.

Supported formats and limitations

  • The top level must be an object. Arrays inside it become indexed names, such as FEATURE_FLAGS__0.
  • camelCase and kebab-case keys become UPPER_SNAKE_CASE, such as logLevel to LOG_LEVEL.
  • If two paths become the same name, such as a_b and a.b with the A_B separator, nothing is converted and both paths are listed.
  • Values with spaces, # or quotes are quoted. Single quotes are preferred because most loaders do not expand $ inside them.
  • null becomes an empty value. Empty objects and arrays are left out.

Examples

Nested keys

{"database": {"host": "db"}} becomes DATABASE__HOST=db.

{"database": {"host": "db"}}

A value with a space

p@ss word is written as DATABASE__PASSWORD='p@ss word'.

{"database": {"password": "p@ss word"}}

Common errors and solutions

The top level must be an object.
Each top-level key becomes a variable name, so an array or a single value has no names. Wrap it in an object.
both become
Two keys turn into the same variable name. Rename one, or switch the separator to A__B.

FAQ

Which separator should I pick?
Use A__B if your app reads nested config from the environment with a double underscore, as ASP.NET Core does and pydantic-settings can. Use A_B for flat names, as Spring Boot expects.
Can I check the result?
Paste it into the .env validator, or convert it back with the .env to JSON converter.
Is the JSON uploaded?
No. It is converted in your browser, which matters when it holds secrets.

Related tools

  • ENV to JSON converter

    Convert a .env file to JSON in the browser. Every value stays a string, duplicate keys are errors, and $ references are not expanded.

  • ENV validator

    Check a .env file without converting it. Duplicate keys, missing equals signs, and $ references are errors, and the editor text is not rewritten.

  • JSON formatter

    Validate JSON, then pretty-print it with 2 or 4 spaces or minify it. Invalid JSON produces an error and leaves the output empty.