Env Var Reference Extractor

Paste a shell script, Dockerfile, docker-compose or CI config and get every environment variable it uses — $VAR, ${VAR}, ${VAR:-default}, %VAR% and process.env.VAR — with line numbers, fallback defaults and a defined/undefined check. Export a list, table, JSON, CSV or a ready-to-edit .env.example. Runs entirely in your browser; nothing is uploaded.

Try:
Referenced variables

About this tool

Environment-variable references hide in shell scripts, Dockerfiles, batch files, CI YAML and application code. This scanner turns a pasted file into the exact set of variables it consumes, with line numbers, default values from parameter expansions and a defined/undefined status check.

Use it before writing a .env.example, moving a script into CI, reviewing a Dockerfile, or auditing code that reads process.env, os.environ, System.getenv or similar accessors. The scanner is deterministic and local: it runs in WebAssembly in your browser and never uploads your input.

Worked example

Paste this shell fragment and choose Output → Aligned table:

PORT=${PORT:-8080}
curl "$API_URL/health"
echo "$PORT" # $COMMENTED_OUT

With comments skipped, the result is:

VARIABLE  USES  LINES  DEFAULT  STATUS
API_URL   1     2               undefined
PORT      2     1, 3   8080     defined

To generate a starter .env.example, switch Output to .env.example template; the default from ${PORT:-8080} is carried into the generated value.

Limits and edge cases

FAQ

Does this read my actual environment variables?

No. It scans only the text you paste and the optional “variables you already provide” list. It does not read your machine's environment, shell profile or secrets.

Why does it report variables inside single quotes or here-docs?

The tool is intentionally a deterministic text scanner rather than a full shell interpreter. It catches references in mixed config/code snippets, but that means some shell-only quoting rules are not modelled. Use the line numbers to review any borderline hit.

How do I get only the variables my deployment still needs?

Paste your script or config, paste your known .env values into “Variables you already provide”, and enable “Show only undefined variables”. The output then lists only variables not defined in the pasted file or your provided list.

Can it scan Dockerfiles and Windows batch files?

Yes. Use Auto-detect for most inputs, or set the syntax explicitly to Dockerfile or Windows batch. Dockerfile ENV and ARG lines and Windows set/setx assignments can count as definitions.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool env-var-reference-extractor '#!/bin/sh
PORT=${PORT:-8080}
curl "$API_URL/health"'

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/env-var-reference-extractor/?text=%23%21%2Fbin%2Fsh%0APORT%3D%24%7BPORT%3A-8080%7D%0Acurl%20%22%24API_URL%2Fhealth%22&syntax=auto&output=names&defined=PORT%3D8080%0AAPI_URL%3Dhttps%3A%2F%2Fapi.internal&include_defined_in_source=true&skip_comments=true&ignore=PATH%2C%20HOME%2C%20LC_%2A&only_undefined=true&sort=name

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.