WireGuard Key Generator

A Curve25519 key pair in WireGuard's base64 format, plus an optional preshared key.

Copy the result before closing this tab.

Generate an X25519 key pair encoded as standard base64 for WireGuard. Keep the private key on its peer and share only the public key. Use wg genkey for a local alternative.

What these keys are

A WireGuard peer is identified by a Curve25519 key pair. The private key stays in the [Interface] section of that peer's config and never moves; the public key is what you hand to the other side, where it goes in a [Peer] block. Both are printed as 32 raw bytes in standard base64 — a 44-character string ending in =. That is the entire identity system: no certificates, no authority, no expiry.

Is generating them in a browser reasonable?

Here the honest answer is unusually favourable. The pair comes from your browser's own crypto.subtle.generateKey('X25519') using the browser’s cryptographic implementation, and the private key is never transmitted or stored. You can verify it in the network tab, or simply disconnect from the network and watch this page keep generating. The usual objection to browser key generation is that you must trust the page you loaded; that objection is real, and it is why the SSH page tells you to prefer ssh-keygen for a long-lived production key. WireGuard keys are cheaper to rotate than an SSH identity — you change one line on each side — so the calculus is different, but the rule still holds: for a gateway that guards a production network, run wg genkey yourself.

The preshared key is not a password

The optional preshared key is 32 random bytes mixed into the handshake on top of the Curve25519 exchange. It adds a symmetric layer intended to hedge against future quantum attacks on the key exchange. Configure the same preshared value on both peers, and protect it like the private key. See the WireGuard protocol description.

FAQ

Is this the same as wg genkey?

Yes. wg genkey emits 32 random bytes as a clamped Curve25519 scalar in standard base64, and wg pubkey derives the matching public key — which is exactly what this page produces via your browser's crypto.subtle.generateKey('X25519'). The values are interchangeable: paste them straight into a WireGuard config.

Do I need the preshared key?

It is optional. The extra symmetric key provides an additional layer intended to hedge against future quantum attacks. Configure the same preshared key on both peers and keep it secret.

Should I generate a production gateway key here?

Our honest answer: run wg genkey yourself for a gateway that guards a production network. The key pair here never leaves your browser and generation works offline, but you are still trusting the page you loaded. WireGuard keys are cheap to rotate — one line per side — so this page is well suited to test peers, lab setups and throwaway tunnels.

How generation works

About & privacy

Generated on your device

Web Crypto provides the randomness. Generation works offline after the page has loaded.

No accounts, no saved values

No account or cookies. Self-hosted, cookieless analytics counts page views, outgoing link clicks and which generator type is copied — never a generated value, which stays in this tab until you copy it.

Browser and device security

A compromised browser or device can expose values. For production private keys, use a trusted local tool.

Other generators

All generators ↗