> ## Documentation Index
> Fetch the complete documentation index at: https://www.qovery.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# qovery env

> Environment variable and secret management commands

## Overview

Manage environment variables and secrets for your Qovery services. This command helps you import and parse environment variables.

## Commands

### Import Environment Variables

Import environment variables/secrets for a Qovery service:

```bash theme={null}
qovery env import
```

Optionally pass a `.env` file path as an argument:

```bash theme={null}
qovery env import ./my-vars.env
```

This command allows you to bulk import environment variables from a `.env` file into your Qovery application or container. It will interactively prompt you to select which variables to import, whether to import as environment variables or secrets, and whether to overwrite existing values.

**Flags:**

| Flag     | Description                       |
| -------- | --------------------------------- |
| `--sort` | Sort environment variables by key |

### Parse Environment Variables

Parse environment variables and create a `.env` (dot env) file:

```bash theme={null}
qovery env parse --heroku-json
```

This command parses environment variables from external sources and outputs them in `.env` format. Currently supports parsing Heroku config JSON from stdin.

**Flags:**

| Flag            | Short | Description                                            |
| --------------- | ----- | ------------------------------------------------------ |
| `--heroku-json` | `-j`  | Parse environment variables from a Heroku JSON payload |

## Examples

### Import Variables from File

```bash theme={null}
# Prepare your environment variables in a file
cat > vars.env <<EOF
API_KEY=your-api-key
DATABASE_URL=postgresql://localhost:5432/mydb
FEATURE_FLAG=enabled
EOF

# Import to Qovery service (interactive)
qovery env import vars.env
```

### Import Variables Sorted by Key

```bash theme={null}
qovery env import vars.env --sort
```

### Parse Variables from Heroku

```bash theme={null}
# Export config from Heroku and pipe to qovery env parse
heroku config -a <your_heroku_app_name> --json | qovery env parse --heroku-json
```

### Development Workflow

```bash theme={null}
# 1. Parse environment variables from Heroku and save to .env
heroku config -a my-app --json | qovery env parse --heroku-json > .env

# 2. Use .env file locally
cat .env

# 3. Run your application locally with same variables
npm run dev  # or your local dev command
```

## Managing Service-Specific Variables

For managing environment variables of specific services, use the service-specific commands:

```bash theme={null}
# Application environment variables
qovery application env list
qovery application env create --key "API_KEY" --value "secret"

# Database environment variables
qovery database env list

# Container environment variables
qovery container env list

# Cronjob environment variables
qovery cronjob env list

# Lifecycle job environment variables
qovery lifecycle env list
```

## Tips

<Tip>
  Use `qovery env import` to migrate environment variables from another platform or bulk-update variables for your services.
</Tip>

<Tip>
  Use `qovery env parse --heroku-json` to keep your local development environment in sync when migrating from Heroku.
</Tip>

<Warning>
  Never commit `.env` files containing secrets to version control. Add `.env` to your `.gitignore` file.
</Warning>

## Related Commands

* [`qovery application env`](/cli/commands/application) - Manage application environment variables
* [`qovery environment env`](/cli/commands/environment) - Manage environment-level variables
* [`qovery container env`](/cli/commands/container) - Manage container environment variables
* [`qovery cronjob env`](/cli/commands/cronjob) - Manage cronjob environment variables
* [`qovery lifecycle env`](/cli/commands/lifecycle) - Manage lifecycle job environment variables
