DevTools Logo

Dotenv Template Generator

Dotenv Template Generator

Turn a real .env into a safe .env.example: values stripped, comments kept, secret-shaped keys flagged.

Runs in your browser
Try an example

Real .env input

.env.example output

Paste a .env to build its template

Input is never stored in this browser and never uploaded. Review the output before committing.

    Examples

    Safe template

    Input
    DATABASE_URL=postgres://user:secret@host/db
    Output
    DATABASE_URL=

    The connection string, including credentials, is removed.

    Sorted comments

    Input
    # server
    PORT=3000
    HOST=localhost
    Output
    HOST=
    # server
    PORT=

    Comment blocks travel with the key they document.

    Type hints

    Input
    PORT=3000
    DEBUG=true
    Output
    PORT=0 # number
    DEBUG=true # boolean

    Contributors see the expected value shape without a real value.

    About this tool

    A .env.example file tells contributors which environment variables a project needs without revealing the values used locally. This tool builds one from a real .env in a single pass: values are removed or replaced, comments and blank-line grouping are kept, and keys can be sorted alphabetically.

    The parser understands the dotenv family grammar — export prefixes, quoted and multiline values, inline comments and duplicate keys. Lines that cannot be parsed are listed with their number and a reason instead of being silently dropped.

    Because the input contains secrets, it is never persisted: no localStorage, no URL sharing and no network request. Secret-shaped keys (pass, token, key, credential) and known token prefixes are flagged in the warnings panel as a final manual-review prompt before the template is committed.

    What this tool does not do

    • Only one .env file is processed at a time; there is no multi-file merge.
    • Secret detection is heuristic and cannot prove that a value is safe.
    • FR-9/FR-10 extras such as README table export and preset headers are not implemented.
    • Values are never edited in place — the output is always a new template.

    How to use this tool

    1. Paste a real .env

      Paste the file or upload it. The content stays in this browser tab.

    2. Choose a value policy

      Strip values, insert kebab-case placeholders, or write type-hint values such as 0 and true.

    3. Tidy the structure

      Optionally sort keys alphabetically and prepend a copy-to-.env header.

    4. Review and export

      Check the secret warnings, then copy the template or download .env.example.

    Use cases

    Open-source onboarding

    Ship a .env.example that documents every variable without leaking a developer's local secrets.

    Repo hygiene

    Standardise environment templates across services with sorting, headers and consistent placeholders.

    Incident review

    Share the shape of a broken configuration with a teammate while leaving credentials behind.

    Value policies

    PolicyInput line
    StripAPI_KEY=sk_live_abc
    PlaceholderDATABASE_URL=postgres://…
    Type hint (number)PORT=3000
    Type hint (boolean)DEBUG=true
    Type hint (URL)HOST=https://example.org

    Existing inline comments are preserved in every policy; a generated type hint is added only when there is no comment already.

    Common mistakes

    Mistake:Treating the warnings as a guarantee.

    Fix:Heuristics flag likely secrets; review the generated template yourself before committing it.

    Mistake:Committing the original .env by mistake.

    Fix:Add .env to .gitignore and commit only the generated .env.example.

    Mistake:Assuming sorting rewrites values.

    Fix:Sorting moves keys and their comments only; values follow the selected policy.

    Frequently asked questions

    Why should I commit a .env.example?

    It documents which variables a project needs so new contributors can get started without asking around. The real .env stays local and untracked; the example contains keys, comments and placeholder values only.

    How are the values removed?

    Choose Strip for empty values, Placeholder for a kebab-case hint derived from the key (DATABASE_URL becomes your-database-url-here), or Type hints for a value that shows the expected shape: 0 for numbers, true for booleans, https://example.com for URLs.

    Are comments preserved?

    Yes. Full-line comments stay in place, inline comments stay on their key, and blank-line grouping is kept. When you sort keys alphabetically, each comment block moves together with the key it documents.

    How does it flag secrets?

    Keys containing pass, secret, token, key, credential or auth are flagged, as are values with known prefixes such as sk_, ghp_ and AKIA. A long mixed-case, mixed-character value on a matching key is also flagged. These are hints for manual review, not a proof that the template is clean.

    Is my real .env stored or uploaded?

    No. The tool opts out of the shared input persistence: nothing is written to localStorage, nothing is put in the URL, and no network request is made. Close the tab and the input is gone.

    What happens to invalid lines?

    Lines that are not KEY=value pairs, keys containing spaces, and unclosed quoted values are skipped. A warning lists each skipped line number and the reason, and the remaining valid keys still produce a template.

    References & standards