Skip to content

Developers

Env JSON Converter

Env JSON Converter

Beta

Turn a .env file into a flat JSON object, or JSON back into KEY=value lines, in your browser. Values stay strings like process.env. Secrets are not uploaded.

  • Free, no sign-up
  • Updated
  • Reviewed by Olgun Ozoktas

The .env text is converted in your browser and is not uploaded to FindUtils. Analytics and ads may load on the page.

.env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
JSON

The flat JSON object will appear here..

How to convert .env to JSON

  1. Paste or upload the .env

    Paste the file text into the left panel or upload the .env file. The three samples show a Node or Vite file with a duplicate key, a Docker Compose file, and a CI file where every line starts with export.
  2. Choose the options

    Leave Infer types off to keep every value a string. Turn it on when a downstream schema expects numbers and booleans. Skip empty values leaves out keys with no value.
  3. Read the warnings

    A duplicate key is listed with its line numbers and the note that the last value was used. A line without an equals sign stops the conversion and names the line, so nothing is silently dropped.
  4. Copy or download

    Copy the JSON from the right panel or download it as env.json. Switch the direction to turn JSON back into a .env; the current output moves into the input so you can round-trip.

Common Use Cases

Secrets manager import

Vault, AWS Secrets Manager, Doppler and similar tools accept a JSON object of key-value pairs. Convert the .env once and paste the JSON into the import form.

Test fixtures and typed config

Turn a real environment into a JSON fixture for a test suite, or check the keys against a JSON schema before a deploy.

Reading a long .env as data

A JSON object with 80 keys is easier to search and diff than 80 lines of shell-style text, and the duplicate report shows what the loader would keep.

JSON config back to dotenv

A platform exported the environment as JSON. Convert it back to KEY=value lines, with the export prefix if a shell will source the file.

Why convert a .env file to JSON in the browser?

A .env file is a list of secrets. The moment you need it as JSON, for a secrets manager import, a CI fixture, or a typed config check, the choices are to retype every KEY=VALUE pair by hand or to paste production credentials into a website that sends them to a server. This page does the conversion in the tab. It reads the file the way a dotenv loader does: comments, an export prefix, single and double quotes, backslash escapes, a double-quoted value that spans several lines, and duplicate keys where the last one wins. Every value stays a string, because that is what process.env holds; the Infer types switch promotes unquoted numbers and booleans only when you ask. The reverse direction writes KEY=value lines back and quotes only the values that need it.

The dotenv format looks trivial and is not. A loader has to skip comments and blank lines, accept an optional export prefix, strip single or double quotes, apply backslash escapes inside double quotes only, let a double-quoted value run across several lines, cut an inline comment after an unquoted value, and decide what happens when a key appears twice. FindUtils' Env JSON Converter implements those rules and turns the result into a flat JSON object with one string per key, the same shape a Node process sees in process.env.

The page is deliberately browser-only. A .env file is the most sensitive text file in most projects, so nothing is sent to FindUtils and there is no REST or MCP surface for this tool. The Env Linter next door checks the same text for duplicate keys, unquoted spaces and drift against .env.example; this page changes its shape. For other config formats, the JSON YAML Converter, the JSON TOML Converter and the Properties JSON Converter follow the same two-pane pattern.

What the converter does not do is also part of the contract. It does not expand $VAR references, run command substitutions or parse shell grammar, because a .env file is not a shell script even when a shell can source it. It does not build a nested object from DB_HOST-style prefixes, because the file is flat and a guessed tree would be wrong for someone. And it does not upload anything, which is the reason it exists.

How it compares

Most env-to-JSON converters online post the text to a server and return the result, which is exactly the wrong design for a file full of credentials. Some run in the browser but invent a nested structure from underscores, or coerce every numeric-looking value into a number, so a port becomes an integer and a zero-padded id loses its zeros. FindUtils keeps values as strings by default, keeps the object flat, and reports duplicates instead of hiding them.

Compared with a one-line script, the page adds the parts people get wrong: multi-line quoted values, escapes, inline comments and the export prefix. Compared with the Env Linter, it converts instead of reporting. Use the linter to find the mistake and this page to move the data.

Dotenv Conversion Tips

  • Keep Infer types off unless the consumer expects numbers. A dotenv loader gives every value to the process as a string, and "3000" and 3000 are different in JSON.
  • A duplicate key is not an error in most loaders; the last value wins. The warning tells you which lines collided so you can remove the dead one.
  • An unquoted # after a space starts a comment. Quote the value when it needs a literal hash, for example a colour or a URL fragment.
  • Nested config is not invented. DB_HOST and DB_PORT stay two flat keys, because that is what the file says. Use a config library if you want a tree.
  • Values that contain spaces, quotes, a hash or a newline are quoted on the way back to .env; everything else is written bare, the way people write these files.

Frequently Asked Questions

Is my .env uploaded anywhere?

No. The conversion runs in your browser and no request carries the text. This is why the tool has no REST or MCP version: the input is usually secrets, and the safest server is no server. Third-party analytics and ads may still load on the page, as on the rest of the site.

Why are numbers and booleans quoted in the JSON?

Because a dotenv loader hands every value to the process as a string. PORT=3000 becomes "3000" in process.env, so the JSON says "3000" too. Turn on Infer types when the consumer expects real numbers and booleans; unquoted integers, decimals, true, false and null are then promoted, and quoted values stay strings.

What happens to duplicate keys?

The last value wins, which is what most loaders do, and the key is listed under Warnings with every line number it appeared on. The JSON keeps the key in the position where it first appeared.

Does it handle quotes, escapes and multi-line values?

Yes. Single quotes keep the value literal. Double quotes apply the escapes \n, \r, \t, \" and \\, and a double-quoted value may span several lines, which is how people store a PEM key in a .env. Unquoted values end at an inline # comment that follows a space.

Does it expand $VAR or run commands?

No. The tool reads the dotenv format only. Variable expansion, command substitution and the rest of shell grammar are outside its scope, so a value like $HOME stays the literal text $HOME.

Can it turn DB_HOST and DB_PORT into a nested db object?

No, on purpose. A .env file is flat, and a tree guessed from underscores is wrong for some file. The JSON stays flat with one key per line. If you need nested config, convert the flat object with your config library.

What does the JSON to .env direction do with nested JSON?

It stops with the message that the root must be a flat object of scalars. Objects and arrays are not flattened into invented key names. Strings, numbers, booleans and null are accepted; null becomes an empty value.

When are values quoted on the way back to .env?

Only when they need it: a value with whitespace, a hash, a quote character, a backslash or a newline is written in double quotes with escapes. Everything else is written bare. Turn on Quote every value if your loader prefers quotes everywhere, and export prefix if a shell will source the file.

What does a line without an equals sign do?

It stops the conversion and names the line, for example Line 4: no "=" on this line. A converter that skipped the line would drop data silently. Fix or remove the line and convert again; comments and blank lines are fine.

Is there a size limit?

The page accepts up to one million characters, far beyond any real .env. Conversion is instant for normal files because everything happens in the tab.

Rate This Tool

0/1000

Get Weekly Tools

Suggest a Tool