#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
🔄 FREE · .ENV ⇄ JSON

.env to JSON Converter: Move Settings Between Formats Cleanly

Paste a .env file and get JSON, or paste JSON and get a .env, with quoting done for you.

  • 💬 Comments and export handled
  • 🔁 Duplicate keys flagged
  • 🙈 Optional secret masking

How to use the Env File to JSON Converter

  1. 1. Pick the direction.env to JSON, or JSON to .env.
  2. 2. Paste the contentComments, blank lines and quoted values are fine.
  3. 3. Copy or downloadGet env.json or a .env file ready to use.

How the sample converts

The sample has a comment, an export line, a quoted value with a space, a double-quoted value with \n and an unquoted value followed by a # comment. The result is 6 variables: NODE_ENV is production (export is removed), APP_NAME keeps its space as Uncodemy Tools, GREETING contains a real line break, API_URL loses the trailing comment and EMPTY is an empty string. Every value stays a string, the same way process.env and os.environ hold them.

Going the other way, JSON values with spaces, quotes or line breaks are wrapped in double quotes and escaped, numbers and booleans become plain text, and nested objects are stored as JSON strings.

Parsing rules

  • Blank lines and lines starting with # are skipped.
  • Unquoted values are trimmed and lose anything after a space and #.
  • Double quotes support \n, \t and escaped quotes; single quotes are taken literally.
  • A quoted value can continue across lines until its closing quote.
  • If a key appears twice, the last value wins and the key is listed as a duplicate.

Different libraries (dotenv for Node, python-dotenv, Docker's env_file) disagree on a few edge cases such as variable expansion with ${VAR}, which this tool leaves as text. Conversion runs in your browser, but treat real production secrets carefully wherever you paste them. Tick masking to replace values of keys with KEY, SECRET, TOKEN or PASSWORD in their names. Keep the .env out of Git with the .gitignore generator and tidy the JSON with the JSON formatter.

Frequently asked questions

Why are numbers shown as strings in the JSON?

Environment variables are always text. Your app converts them, for example Number(process.env.PORT).

Does it expand ${OTHER_VAR}?

No. Expansion depends on the library, so the value is kept exactly as written.

Is the Env File to JSON Converter free?

Yes, the Env File to JSON Converter is free. The first time you convert your first file, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.

More free tools

See all free tools