Shard Tools

ENV to JSON

Turn a .env file into JSON in your browser.

Maintained by Roshan.

Use ENV to JSON

Converts .env text into JSON in this tab. Configuration files routinely hold hostnames, keys and credentials, so nothing here is sent anywhere.

Values are never retyped as numbers or booleansGuessing types is how a converter turns a postcode of 0123 into 123, or a literal string of false into a boolean. Values are carried across as they were written, and casting is left to you where it matters.

Explore developer and data tools

Find related browser-local tools for nearby tasks without starting another search.

Browse all developer and data tools

About ENV to JSON

A .env file is the most sensitive text file in a typical project. It is where database passwords, API keys and signing secrets live, which makes pasting one into an unfamiliar website a genuinely bad idea and makes a local converter worth having. The format looks trivial and has more corners than expected. Values may carry an optional export prefix left over from shell usage. Quotes are significant: double quotes allow escape sequences while single quotes are literal, and an unquoted value ends at the first inline comment. Getting those rules wrong produces a config that looks right and behaves subtly differently, which is the worst possible outcome for a file that controls what your application connects to.

Work through the input

  1. Each line is read as a key and value pair, with an optional export prefix stripped since it is left over from files meant to be sourced by a shell.
  2. Double-quoted values have their escape sequences interpreted, so a written backslash-n becomes a real newline.
  3. Single-quoted values are taken literally, with no escape processing, matching how shells and dotenv libraries treat them.
  4. An unquoted value ends at the first inline comment marker, so a trailing note after a hash is not absorbed into the value.
  5. Blank lines and whole-line comments are skipped, and keys are required to be valid variable names so stray text does not become configuration.

When env to json is useful

Inspecting a config you inherited

Converting to JSON makes it easy to see what is actually set, especially in a long file with mixed quoting styles.

Building a config object for a script

The JSON output can be pasted straight into code, though remember every value is a string and ports or flags need casting.

Check the output

Questions about ENV to JSON

Is it safe to paste my .env here?

It never leaves your browser, so yes in the sense that nothing is transmitted. As a general habit, treat any website asking for a .env with suspicion - the reason this one is safe is that there is no endpoint to receive it.

What is the difference between quote styles?

Double quotes interpret escape sequences such as backslash-n; single quotes are literal. Unquoted values end at an inline comment.

Are variable references expanded?

No. A value referencing another variable is left exactly as written.

Why is my number a string?

Because environment variables are always strings. Cast them in your application where the type matters.

Are comments preserved?

No, JSON cannot hold them. Keep the original file for the explanations.

Related tools

JSON to ENV

Turn a JSON object into .env format in your browser, with keys upper-cased and values quoted where a shell needs it.

INI to JSON

Turn an INI configuration file into JSON in your browser. Sections become nested objects and values stay strings.

YAML to JSON Converter

Convert YAML to JSON or JSON to YAML in your browser. Handles multi-document files, follows YAML 1.2, and uploads nothing.