CoreJSON

JSON to .env

This tool converts a JSON object into .env key/value text. Nested fields are flattened into dot-path keys such as server.host, and you can add an export prefix or convert keys to UPPER_SNAKE_CASE for shell compatibility. It is a handy way to export a configuration object as an environment file, and the conversion runs entirely in your browser — nothing is uploaded.

Open in the workbench Runs locally · nothing is uploaded

How to use it

  1. 1

    Paste a JSON object

    The root must be an object; nested values are flattened using your chosen separator, or pick a local .json file.

  2. 2

    Choose a path separator

    Use a dot, underscore, slash or hyphen between path segments.

  3. 3

    Adjust the key style

    Optionally add an export prefix, or uppercase keys and join them with underscores.

  4. 4

    Copy the result

    Take the .env text and drop it into your project root, or switch to the reverse direction to go back to JSON.

Key features

Nested flattening

Keys such as server.host and server.port are generated automatically, so you never write them by hand.

Key style options

Switch the separator between dot, underscore, slash or hyphen and uppercase the keys to match shell variable conventions.

Optional export prefix

Emit export KEY=value so the file can be sourced directly into a shell.

Automatic quoting

Values containing spaces or special characters are quoted automatically so the shell reads them correctly.

Round-trip friendly

Pairs with the reverse direction to turn a .env file back into JSON.

Local and private

The conversion runs in a Web Worker in your browser; secrets in your config are never uploaded.

Common errors & troubleshooting

  • ! The root node must be an object; an array or a scalar reports a semantic error, and arrays expand into keys such as key[0] and key[1].
  • ! Values containing spaces or special characters are quoted automatically; you can add your own quotes if you need to force quoting.
  • ! Uppercase keys joined with underscores are the safest choice for shell variables, where lowercase names are unusual.
  • ! If the flattening looks wrong, check the separator — a key that already contains a dot can be ambiguous once flattened.

Frequently asked questions

Are quotes around values preserved?

Strings are written as-is, and values containing spaces or special characters are quoted automatically so the shell does not misread them.

Can I convert a .env file back to JSON?

Yes. Switch to the reverse direction (.env to JSON) on the same page, and optionally enable type inference to restore numbers and true / false.

Why are my keys flattened?

A .env file is flat, so nested objects are turned into dot-path keys. Choose a different separator or casing if your tooling expects a particular style.

Is my data uploaded?

No. The conversion runs locally in your browser; nothing leaves your device.

Related tools