Skip to content
gohacks.dev
DevOps

.env File Diff

Compare two .env files key by key and see which variables are missing, empty or different, with secret values masked by default.

Free · No sign-up · Your inputs stay in your browser

Input

Compare two .env files

Output

9 keys, 4 missing or empty

KeyABStatus
APP_DEBUGtruefalsedifferent
APP_ENVlocalproductiondifferent
APP_URLhttp://localhosthttps://example.comdifferent
DB_HOSTmysql10.0.0.5different
DB_PASSWORD•••(empty)empty in B
MAIL_MAILERsmtp-only in A
QUEUE_CONNECTIONsyncredisdifferent
REDIS_HOST-10.0.0.6only in B
SENTRY_DSN-•••only in B

The usual failure is a key added to .env.example and to local but never to production, which surfaces as a null config value at runtime. Comments and export prefixes are ignored; quoted values are compared without their quotes.

Runs in this browser. Nothing you paste is sent to a server.

The bug it catches

A variable is added to .env.example and to a developer's .env, the feature ships, and production has no such key: the config value is null and the failure shows up far from its cause. Comparing .env.example with the environment a server actually has, before deploying, catches it. Laravel's php artisan env and config:show help confirm what was loaded.

Paste with care

Production .env files contain credentials. This comparison runs in the browser and nothing is sent, but the safest habit is to paste with values redacted, since only the keys are needed to find what is missing.

Share

Frequently asked questions

How do I diff .env files in a terminal?
diff <(cut -d= -f1 .env.example | sort) <(cut -d= -f1 .env | sort) compares the keys only, which is usually what you want and keeps values off the screen.
Why is a value different when the text looks the same?
Often quoting: "value" and value are equal after parsing, so they are compared without quotes here, but trailing spaces and different line endings are real differences.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools