﻿# Declarations

> Declare variable names and the rules they must follow

[Dotenv.toml](/docs/dotenv-toml/)

Save the file as `Dotenv.toml` in your project directory. It contains names and rules. Values stay in `.env` or your other environment sources.

Declare each variable as a table such as `[env.DATABASE_URL]`. Variable names are case-sensitive and must match `[A-Za-z_][A-Za-z0-9_]*`. Comments begin with `#`.

```toml
# Dotenv.toml
strict = true

[env.DATABASE_URL]
type = "url"
required = true
storage = "encrypted"
redacted = true

[env.SENTRY_DSN]
optional = true
```

Variables are optional by default. The default type is `"string"`, storage is `"any"`, and redaction is off. Set rules explicitly or use root settings to change the defaults.

Put each setting on its own line within the table.

```toml
[env.PORT]
type = "port"
storage = "plaintext"
redacted = false
```

## Settings

- [Required](/docs/dotenv-toml/required/)
- [Optional](/docs/dotenv-toml/optional/)
- [Types](/docs/dotenv-toml/type/)
- [Choices](/docs/dotenv-toml/enum/)
- [Minimum](/docs/dotenv-toml/min/)
- [Maximum](/docs/dotenv-toml/max/)
- [Encryption](/docs/dotenv-toml/encrypted/)
- [Redaction](/docs/dotenv-toml/redacted/)

## Related

- [Dotenv.toml Quickstart](/docs/dotenv-toml/quickstart/)
- [Full Dotenv.toml Spec](/docs/dotenv-toml/spec/)
