Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Node.js Basics 2017 Create a Command Line Weather Application Retrieving Data - Solution

.env Vs. api.json

Prior to this lesson I've been storing API keys in a hidden .env file and using process.env.API_KEY to access it.

Is there a benefit to using api.json over .env? Is one approach more secure than the other?

1 Answer

Heidi Fryzell
.a{fill-rule:evenodd;}techdegree seal-36
Heidi Fryzell
Front End Web Development Treehouse Moderator 25,046 Points

Hi there,

Thanks for reaching out. I honestly don't know the answer to your question, it goes it little beyond my present experience level. I did do a Google search to try and understand what you were asking and this article might be helpful:


It talks about why you should use environment variables with a .env file over a config.json file.

I hope this helps in some way and happy coding! Heidi

Thanks Heidi , the article is a well written article on working with .env

Up until this tutorial I thought .env was the standard for hiding sensitive information. I'm familiar with using .env, I'm just wondering if using api.json like Andrew did is a good convention for modern day? I've never seen it done like this before.

Most frameworks seem to use .env. I am somewhat new to this as well. Thanks!