.env · security🔒 100% client-side — never leaves your browser

WordPress Salts Generator

Generate WordPress salts and security keys in your browser: this WordPress salts generator creates all 8 keys (AUTH_KEY to NONCE_SALT) as a wp-config.php block, as a Bedrock .env and as WORDPRESS_* variables for the official Docker image.

By Aliniyaz Mamat · last reviewed

Be the first to rate
generated locally · crypto.getRandomValues · nothing sent anywhere
wp-config.php block
define( 'AUTH_KEY', '' );
define( 'SECURE_AUTH_KEY', '' );
define( 'LOGGED_IN_KEY', '' );
define( 'NONCE_KEY', '' );
define( 'AUTH_SALT', '' );
define( 'SECURE_AUTH_SALT', '' );
define( 'LOGGED_IN_SALT', '' );
define( 'NONCE_SALT', '' );
.env for Bedrock (roots/bedrock)
AUTH_KEY=''
SECURE_AUTH_KEY=''
LOGGED_IN_KEY=''
NONCE_KEY=''
AUTH_SALT=''
SECURE_AUTH_SALT=''
LOGGED_IN_SALT=''
NONCE_SALT=''
.env for the official WordPress Docker image
WORDPRESS_AUTH_KEY=''
WORDPRESS_SECURE_AUTH_KEY=''
WORDPRESS_LOGGED_IN_KEY=''
WORDPRESS_NONCE_KEY=''
WORDPRESS_AUTH_SALT=''
WORDPRESS_SECURE_AUTH_SALT=''
WORDPRESS_LOGGED_IN_SALT=''
WORDPRESS_NONCE_SALT=''
AUTH_KEY
SECURE_AUTH_KEY
LOGGED_IN_KEY
NONCE_KEY
AUTH_SALT
SECURE_AUTH_SALT
LOGGED_IN_SALT
NONCE_SALT

Key takeaways

  • ✓8 values, 64 characters each, from 92 characters: letters, digits, space and symbols, without ' and \ so they cannot break the PHP string.
  • ✓Changing the salts logs out every user immediately: the standard first step after a hacked site or a leaked wp-config.php.
  • ✓In .env files the values are single-quoted, because salts contain $, #, spaces and backticks.
  • ✓Nothing is requested from api.wordpress.org; the values come from crypto.getRandomValues in this tab.

What it does

  • ▸All 8 WordPress keys and salts in one click
  • ▸wp-config.php define() block, Bedrock .env and WORDPRESS_* Docker .env
  • ▸Safe charset for PHP single-quoted strings (no ' or \)
  • ▸Unbiased random selection from the Web Crypto API
  • ▸Generated locally, nothing sent or stored

Privacy

Runs 100% in your browser. Your .env never touches our servers.

client-side only

When to use this tool

  • →A new WordPress install, instead of calling the api.wordpress.org salt service
  • →Forcing all users (including an attacker's session) to log out after a compromise
  • →Bedrock or Trellis projects that keep salts in .env
  • →Docker Compose setups with the official wordpress image

Common mistakes

  • ⚠Keeping put your unique phrase here from wp-config-sample.php. All sites with that value share predictable keys
  • ⚠Pasting .env values without quotes: $ and # inside the salt get expanded or cut off
  • ⚠Using single quotes with docker run --env-file: plain Docker keeps the quotes as part of the value. Quotes are for Compose, Bedrock and dotenv
  • ⚠Rotating salts on a busy shop without warning: every customer is logged out and loses an unsaved session

What the 8 WordPress keys and salts do

WordPress signs its login cookies and nonces with HMACs. The keys and salts in wp-config.php are the secret input to those HMACs, grouped by cookie type:

PairProtects
AUTH_KEY / AUTH_SALTthe auth cookie for /wp-admin over plain HTTP
SECURE_AUTH_KEY / SECURE_AUTH_SALTthe auth cookie over HTTPS
LOGGED_IN_KEY / LOGGED_IN_SALTthe cookie that marks a visitor as logged in on the front end
NONCE_KEY / NONCE_SALTnonces in forms and URLs (CSRF protection)

Together with read access to the database (password hashes and session tokens), these values are enough to forge a valid login cookie. A leaked wp-config.php contains both the salts and the database password, so it means: new salts, new database password, new admin passwords.

Where to put the salts

Classic install: wp-config.php

Replace the 8 define() lines between /**#@+ and /**#@-*/ with the block above. Save, then log in again.

Bedrock: .env

.env
WP_ENV='production'
WP_HOME='https://example.com'
WP_SITEURL="${WP_HOME}/wp"
AUTH_KEY='…'
SECURE_AUTH_KEY='…'
# … all 8 keys

Official Docker image: compose.yaml + .env

compose.yaml
services:
  wordpress:
    image: wordpress:6
    env_file: .env          # WORDPRESS_AUTH_KEY=… etc.
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: wp
      WORDPRESS_DB_NAME: wp

Keep the .env out of git and the image, the same way as for any other app. The guide how to hide .env from git shows the .gitignore and .dockerignore lines.

Rotating salts after a security incident

  1. Generate new values here (or run wp config shuffle-salts with WP-CLI on the server).
  2. Replace all 8 values at once, not just one pair.
  3. Change all administrator passwords and the database password in DB_PASSWORD.
  4. Remove unknown administrator accounts and application passwords under Users.
  5. Check wp-content/plugins and wp-content/mu-plugins for files you did not install.

New salts end every session, including an attacker's stolen cookie. They do not remove a backdoor file. That is what steps 4 and 5 are for.

Frequently asked questions

What are WordPress salts?

Eight random strings in wp-config.php (AUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY, NONCE_KEY and their _SALT partners) that WordPress uses to sign login cookies and nonces.

What happens if I change the salts?

All existing login cookies stop validating, so every user is logged out and must sign in again. Content, users and settings are not affected.

Why are there no single quotes or backslashes in the values?

wp-config.php defines the constants inside single-quoted PHP strings. A ' would end the string and \ can escape the closing quote; both would cause a fatal error.

Do I need the api.wordpress.org salt generator?

No. https://api.wordpress.org/secret-key/1.1/salt/ returns random values of the same kind. Generating them locally gives the same result without an external request.

What if I don't set WORDPRESS_* keys in Docker?

The official image fills random values into wp-config.php when it first creates the file. Setting them yourself keeps them stable when the container and its volume are recreated.

Related tools

Learn more

Compare

coming soon

Get notified when env syncing launches

We're building a tiny tool to keep .env files in sync across teammates and environments. Leave your email — no spam, just a single launch ping.

We use your address only for this launch email. You can ask us to delete it at any time. Privacy policy