Skip to main content
Developer Documentation / Project Tools

.env Validator

Check a .env file for invalid keys, duplicates, spaces around =, unclosed quotes and other dotenv syntax problems - values are never shown.

Paste a .env or .env.example file to find syntax problems by line number - the report never displays values, and the check runs in your browser.

Checked entirely in your browser. The report shows key names and line numbers only - values are never displayed, stored or sent. Even so, prefer pasting .env.example rather than a file with live secrets.

Prefer validating .env.example over a file with live production secrets.

What Is the .env Validator?

It checks the syntax of a .env or .env.example file line by line and reports problems with the line number and key name. Values are never shown in the report, and nothing leaves your browser.

Why It Matters

Dotenv files look simple, but loaders disagree on the details. A space around = works in one library and breaks Docker's --env-file; an unquoted # silently cuts a value short; a duplicate key means the value you see is not the value your app gets. These mistakes rarely produce a clear error - the app just behaves strangely.

How to Use It

  1. Paste the file (preferably the .env.example version) or click Load sample.
  2. Choose which optional checks to run.
  3. Click Validate and fix the errors first, then review the warnings.

What It Checks

  • Errors: lines without =, invalid key names (must be letters, digits and underscores, not starting with a digit), spaces around =, duplicate keys, unclosed quotes.
  • Warnings: lowercase keys, unquoted values with spaces or #, text after a closing quote, trailing whitespace, the export prefix, multi-line values, CRLF line endings, a byte-order mark, and ${VAR} references to variables not defined in the file.
  • Empty values: listed separately - normal in an example file, worth checking in a real one.

Limitations

The validator checks syntax, not meaning: it cannot tell whether a database password is correct or a URL is reachable. Parsers differ, so a warning means "may behave differently between tools", not always "broken". Avoid pasting live production secrets into any website, including this one. To start a fresh file, use the .env Generator; to convert variables between formats, use the Environment Variable Formatter.

Frequently Asked Questions

The check runs entirely in your browser and the report shows only key names and line numbers, never values. Still, the safest habit is to validate the .env.example version rather than a file with live production secrets.

Some dotenv libraries trim the spaces, but Docker --env-file and shell source treat them as part of the key or value, so the variable ends up with the wrong name or a leading space. Writing KEY=value works everywhere.

Most loaders treat an unquoted space followed by # as the start of a comment, so everything after it is dropped. Wrap the value in quotes if the # is part of it, for example a password or a colour code.

It depends on the loader: most use the last value, some the first, and a real environment variable may override both. The validator reports every duplicate with the line of the first definition so you can remove one.
Share this tool: