HandyBench

.env.example Generator

Strip secrets to build a .env.example.

How to use the .env.example Generator

  1. 1 Paste the contents of your .env file.
  2. 2 Choose how values are shown: blank, a placeholder, or kept as examples.
  3. 3 Copy the generated .env.example for your repo.

What the converter does line by line

It reads your .env text one line at a time and applies a short rule list. The output updates live as you type, and nothing is sent anywhere.

  1. A blank line stays blank.
  2. A line that starts with # is a comment, kept or dropped depending on the "Keep comments" checkbox.
  3. A line shaped like KEY=value is processed. The key must start with a letter or underscore and may contain letters, digits, underscores, dots and hyphens, with an optional leading export.
  4. If the value opens a quote that is not closed on the same line, the following lines up to the closing quote belong to that value and are never output.
  5. Any other line is left out, and a note under the output says how many were dropped, so a stray value can never reach the file.

For a recognised KEY=value line, the value style decides what follows the equals sign.

Value styleInputOutput
BlankAPI_KEY=sk_live_51H8xAPI_KEY=
PlaceholderAPI_KEY=sk_live_51H8xAPI_KEY=<your_api_key>
Keep example valuesPORT=3000PORT=3000 (the whole line unchanged)

Worked example

With the default sample, which has a comment, a database URL, an API key and a debug flag, Blank mode produces:

# Database
DATABASE_URL=
API_KEY=
DEBUG=

Placeholder mode turns the same lines into DATABASE_URL=<your_database_url>, API_KEY=<your_api_key> and DEBUG=<your_debug>, where the placeholder is the lower-cased key name. An export prefix is kept: export DEBUG=true becomes export DEBUG=.

Edge cases it handles

In Blank and Placeholder modes the output is built only from key names, comments and blank lines, so nothing from a value can survive.

  • Multi-line values. A quoted private key spread over several lines becomes a single PRIVATE_KEY= line. The key material and the closing quote are dropped, and an unclosed quote swallows the rest of the input rather than leaking it.
  • Unusual key names. Keys with dots or hyphens, such as my-token=abc123, are treated like any other key. In Placeholder mode the dots and hyphens become underscores, so the placeholder is <your_my_token>.
  • Inline comments. In PORT=3000 # dev, the comment after the value is kept when "Keep comments" is ticked, giving PORT= # dev. A # with no space before it, as in abc#123, is part of the value. A # inside quotes is never treated as a comment.
  • Keep example values mode outputs your text unchanged, so use it only when the values are already safe.

If a real secret ever reached a public repository, deleting it from the file is not enough; it stays in the git history, so rotate the credential. The UUID generator and password generator make fresh values for new keys, and JSON formatter covers config that lives in JSON rather than dotenv.

Examples

  • ▸ Creating a safe .env.example to commit alongside your code.
  • ▸ Documenting required environment variables for a team.

Frequently asked questions

Are my secret values exposed?

No. Everything runs in your browser and nothing is uploaded. In Blank and Placeholder modes the output contains only key names, comments and blank lines: values are removed, multi-line quoted values are dropped entirely, and lines that are not KEY=value are left out. Still glance at the output before committing it.

Does it keep comments and structure?

Yes. Comments and blank lines are preserved (you can toggle comments off), and each KEY=value line keeps its key, including any export prefix, while the value is blanked or replaced with a placeholder.

What do the three value styles do?

Blank turns API_KEY=abc into API_KEY=. Placeholder turns it into API_KEY=<your_api_key>, using the lower-cased key name. Keep example values leaves the line exactly as it was.

What happens to multi-line values such as private keys?

A value that opens a quote and closes it on a later line is treated as one value, so a PEM private key becomes a single KEY= line and none of the key material is output. If the closing quote is missing, everything after the opening quote is dropped rather than copied.

I committed a real secret by mistake. What now?

Rotate the credential. Deleting it from the file does not remove it from git history, so treat it as exposed and issue a new one.