Importing and exporting .env files
Coming in Secret Store 1.3. It's built and arrives with the next update; the version on the App Store doesn't have it yet.
Importing a .env file
On a Mac, choose Secrets ▸ Import .env File…, click + and choose
Import .env File…, or drop a .env file on the Secret Store window. On
iPhone and iPad, tap + and choose Import .env File…. The open panel on
the Mac shows hidden files, so .env is listed even though its name starts with
a dot.
Before anything is saved, a preview shows:
- The keys in the file, by name only. Values are never shown.
- The tag they’ll get:
env/<project>, where<project>is the name of the folder the file is in. You can change it. - What to do with keys that already exist under that tag: update their
values, skip them, or keep both (the new one is saved as
KEY_2). - Lines that were skipped, by line number, and why.
Each key becomes its own secret, named after the key, with the key as its variable name. A comment directly above a key becomes that secret’s description. You can rename the secrets afterwards: importing the file again still finds them by their variable names.
Secret Store reads the usual .env syntax: KEY=value, an optional export
prefix, # comments, double-quoted values with \n, \" and \\ escapes,
single-quoted values taken literally, and values in double quotes that span
several lines, like a private key. It doesn’t expand ${OTHER} references:
they’re saved exactly as written, and the preview says so when it sees one.
Secret Store only reads the file. It isn’t changed or deleted, so once your keys are imported, delete the plain-text file yourself if you don’t need it.
The same key in several projects
Two secrets can share a name as long as their tags differ, so OPENAI_API_KEY
under env/app-a and OPENAI_API_KEY under env/app-b are separate secrets.
When the list shows two secrets with the same name, each row shows its tags
underneath.
Exporting a tag as a .env file
Right-click a tag in the sidebar (on iPhone and iPad, touch and hold it) and
choose Export as .env…. Confirm that the file won’t be encrypted, click
Export…, then approve with Touch ID, Face ID or your password. Every secret
with that tag is written as a KEY="value" line, quoted so it reads back exactly.
If the tag has nested tags, tick Include secrets in nested tags to take in
env/app/… too.
Each line uses the secret’s variable name. A secret without one is left out, not renamed, and listed when the export finishes; so is a second secret with a variable name already written. On a Mac you choose where to save the file; on iPhone and iPad it goes to the share sheet, and the temporary copy is removed when the sheet closes.
The exported file is plain text: anyone who can read it can read your keys.
Variable names
Every secret can have a variable name: the name it gets in an exported .env
file and when a script runs with
secretstore run.
Set it when you add or edit a secret, under Environment variable.
- A new secret gets one suggested from its name as you type: “Stripe key (prod)”
becomes
STRIPE_KEY_PROD. You can change it or clear it. - A secret without one uses its name when that’s already a valid variable name
(letters, digits and
_, not starting with a digit), likeAPI_KEY. - Renaming a secret doesn’t change its variable name.
- Backups, restores and sent secrets keep it.