Secret & API Key Generator

Generate random secret keys, encryption keys, API tokens and database passwords, one at a time or as a .env block, with the Web Crypto API in your browser.

About Secret & API Key Generator

This tool makes random secrets for application config: secret keys, encryption keys and salts, database and cache passwords, and API tokens. Every value comes from crypto.getRandomValues, the browser's cryptographic random source, and characters are picked with rejection sampling so each one is equally likely. Values exist only on the page: they are not sent anywhere, not saved in storage or the address bar, and a new set is made each time the page loads. The Clear button removes them from the page.

Pick a format: a URL-safe base64url token (the default), hex, standard Base64, letters and digits only, a DB/URL-safe password for connection strings, or a password with symbols. Set the strength in bytes of randomness (16 to 64) or as a length in characters, and the tool shows the resulting length and entropy in bits. Bulk mode turns a list of key names into a .env block with a separate fresh value for every key, ready to copy as a whole or line by line.

A hash of a phrase you typed is not a secret: it is only as hard to guess as the phrase. Use a value from a random source instead, give each environment (development, staging, production) its own, and never reuse one across apps.

How to use it

  1. Pick a preset such as App secret key or Database password, or choose a format yourself.
  2. Set the strength in bytes of randomness or as a length in characters, and check the entropy shown.
  3. For a .env file, switch to .env bulk and enter one key name per line.
  4. Click Copy on a value or line, or Copy all for the whole .env block.
  5. Click Regenerate for new values, or Clear to remove them from the page.

Questions

Is anything sent to a server or saved?

No. Values are generated with the Web Crypto API on your device and kept only in the page's memory. Nothing is written to cookies, local storage or the URL, and the clipboard is used only when you click a Copy button.

How many bytes should a secret key have?

32 bytes (256 bits) is plenty for encryption keys and signing secrets. The default of 48 bytes gives extra margin for long-lived app secrets. 16 bytes (128 bits) is the practical minimum.

Why use a DB/URL-safe password?

Database connection strings are URLs, so characters such as @ : / ? # % in a password end or split parts of the URL. Letters and digits never need encoding, so the password works as-is; use a longer one to make up for the smaller character set.

Why does the .env output put some values in quotes?

Values with symbols are wrapped in single quotes, because an unquoted # starts a comment and $ can expand a variable in many .env loaders and shells.

Can I use the same secret for staging and production?

Better not. Separate values mean a leak in one environment does not expose the other, and you can rotate one without touching the rest.

Related tools

Home · All Tools · Blog · Privacy · Terms