Introduction
JSON Web Keys are the standard key format for JWT, JWS, and JWE, but most crypto libraries still expect PEM. If you have a JWK from an authorization server and need it in PEM for OpenSSL, or a PEM key from `openssl genpkey` and need it as a JWK for your JWT library, this converter handles it in your browser. It converts between JWK (RFC 7517), PEM (SPKI and PKCS#8), and DER (base64) for RSA, EC, Ed25519, and symmetric octet keys, using the jose library and WebCrypto. Paste your key, pick the target format, and the converted output appears instantly.
What this tool does
- Convert between JWK (JSON Web Key, RFC 7517), PEM (SPKI public or PKCS#8 private), and DER (base64-encoded SPKI or PKCS#8) formats
- Support RSA keys (modulus, exponents, CRT parameters), EC keys (P-256, P-384, P-521 curves), Ed25519 keys (OKP type, RFC 8037), and symmetric octet keys (kty: oct)
- Auto-detect the key type from the parsed JWK and display it as a badge (e.g. RSA, EC/P-256, OKP, oct)
- Preserve all key parameters across conversions with no data loss, so a round trip JWK to PEM to JWK produces identical output
- Swap input and output formats with one click, moving the current output into the input field to reverse the conversion
- Run entirely client-side via jose and WebCrypto: your key material never leaves your browser
How this tool works
The tool uses the jose library backed by the browser's WebCrypto API. When you paste a JWK, the tool parses the JSON and calls `importJWK` to create a CryptoKey. When you paste PEM, it calls `importSPKI` for public keys (`-----BEGIN PUBLIC KEY-----`) or `importPKCS8` for private keys (`-----BEGIN PRIVATE KEY-----`). For DER input, the base64 bytes are wrapped in PEM headers first, then imported the same way.
Once imported, the tool detects the key type by exporting back to JWK and reading the `kty` field. For EC keys it also reads `crv`. The detected type is shown as a badge next to the output.
For output, the tool calls the appropriate export function. `exportJWK` produces a JSON object stringified with 2-space indentation. `exportSPKI` and `exportPKCS8` produce PEM strings with correct RFC 7468 labels. For DER output, the PEM is base64-decoded and re-encoded as a single base64 string.
The tool prevents exporting a public key as PKCS#8 private, since PKCS#8 requires private key material. The Swap button reverses the format selectors and moves the output into the input field so you can verify the round trip. All operations happen in the browser. No key material is sent anywhere.
How JWK and key formats work (RFC 7517, RFC 7518, RFC 8037)
JSON Web Key (JWK) is specified in RFC 7517. A JWK is a JSON object representing a cryptographic key. The `kty` (key type) parameter identifies the algorithm family: `RSA`, `EC`, `oct`, or `OKP`. The algorithm-specific parameters are defined in RFC 7518 (JSON Web Algorithms) and RFC 8037 (OKP keys for Ed25519 and X25519).
For RSA keys, the JWK contains `n` (modulus, base64url) and `e` (public exponent) for public keys. Private keys add `d` (private exponent), `p` and `q` (prime factors), `dp` and `dq` (CRT exponents), and `qi` (CRT coefficient). These correspond to the PKCS#1 RSAPrivateKey fields. The `key_ops` parameter lists permitted operations (sign, verify, encrypt, decrypt). The `kid` parameter is an optional key identifier for matching keys to JWT headers.
For EC keys, the JWK contains `crv` (P-256, P-384, or P-521), `x` and `y` (public curve point coordinates, base64url). Private keys add `d` (the private scalar). The curve names map to the NIST curves defined in FIPS 186-5. For OKP keys (Ed25519, X25519), the JWK contains `crv` (Ed25519 or X25519), `x` (public key), and optionally `d` (private key).
For symmetric keys (`kty: oct`), the JWK contains `k` (the raw key bytes, base64url). These are used for HMAC keys and AES keys in JWT encryption (JWE). The PEM formats this tool produces are SubjectPublicKeyInfo (SPKI, RFC 5280) for public keys and PKCS#8 (RFC 5208) for private keys. These are the formats that OpenSSL's `genpkey` and `rsa -pubout` produce, and that Java's `X509EncodedKeySpec` and `PKCS8EncodedKeySpec` expect.
How to use this tool
- Select the input format: JWK (JSON), PEM (SPKI public), PEM (PKCS#8 private), DER (SPKI base64), or DER (PKCS#8 base64)
- Paste your key into the input area. For JWK, paste the full JSON object. For PEM, include the BEGIN and END headers. For DER, paste the base64 string
- Select the output format you want to convert to. The tool imports the key via jose and WebCrypto, then exports it in the target format
- Check the detected key type badge to confirm the parser recognized your key (e.g. RSA, EC/P-256, OKP, oct)
- Copy the output. For JWK output, the JSON is formatted with indentation. For PEM output, the headers and line breaks are included. For DER output, a single base64 string is produced
- Click the Swap button to reverse the conversion. The output becomes the input, and the format selectors swap, so you can verify the round trip produces the original key
Real-world examples
Converting a PEM RSA private key to JWK
Input: a PEM block starting with `-----BEGIN PRIVATE KEY-----` (PKCS#8, from `openssl genpkey -algorithm RSA`). Select input format PEM (PKCS#8 private) and output format JWK. The output is a JSON object with `kty: RSA`, `n` (base64url modulus), `e` (base64url exponent, typically `AQAB` for 65537), `d`, `p`, `q`, `dp`, `dq`, and `qi`. This is the format JWT libraries like jose and jsonwebtoken expect for RSA signing.
Converting an EC P-256 JWK to PEM SPKI
Input: `{"kty":"EC","crv":"P-256","x":"MKB...","y":"4Er..."}`. Select input format JWK and output format PEM (SPKI public). The output is a PEM block starting with `-----BEGIN PUBLIC KEY-----` containing the SubjectPublicKeyInfo with the EC public key and an AlgorithmIdentifier for `id-ecPublicKey` with the secp256r1 curve OID. This PEM can be used with OpenSSL for verification.
Converting an Ed25519 key between JWK and PEM
Input: an Ed25519 JWK with `kty: OKP`, `crv: Ed25519`, `x` (public key, 32 bytes base64url), and `d` (private key, 32 bytes base64url). Select output format PEM (PKCS#8 private). The output is a PEM block with an AlgorithmIdentifier for Ed25519 (OID 1.3.101.112). Converting back to JWK reproduces the original `x` and `d` values exactly, confirming the round trip is lossless.
Comparison with similar methods
| Method | Complexity | Typical use |
|---|---|---|
| JWK (RFC 7517) | JSON object, base64url-encoded parameters | JWT, JWS, JWE, OAuth/OIDC, JWKS endpoints |
| PEM SPKI (RFC 5280) | Base64 DER with PUBLIC KEY headers | OpenSSL, nginx, Java X509EncodedKeySpec |
| PEM PKCS#8 (RFC 5208) | Base64 DER with PRIVATE KEY headers | OpenSSL genpkey, Java PKCS8EncodedKeySpec |
| DER SPKI (X.690) | Raw binary ASN.1, base64 for transport | TLS wire format, binary key stores |
| DER PKCS#8 (X.690) | Raw binary ASN.1, base64 for transport | Binary private key storage, HSM import |
Limitations or considerations
This tool converts key formats. It does not generate new keys. For generating RSA, EC, or Ed25519 key pairs, use the Key Pair Generator or the JWK Generator / Parser.
The tool does not handle encrypted PKCS#8 (`EncryptedPrivateKeyInfo`). If your PEM block says `-----BEGIN ENCRYPTED PRIVATE KEY-----`, decrypt it with OpenSSL first (`openssl pkcs8 -nocrypt -in encrypted.pem -out plain.pem`) before pasting it here.
Symmetric keys (`kty: oct`) can be converted from JWK to JWK or stored as raw bytes, but they do not have a standard PEM or DER representation as public or private keys. Attempting to export an oct key as PEM SPKI or PKCS#8 will fail. Oct keys are typically used directly as JWK in JWT contexts.
The tool does not validate key strength. A 1024-bit RSA key or a P-192 EC key will convert without error, but both are deprecated. Use at least 2048-bit RSA and P-256 or stronger for EC keys.
Never paste a production private key into any web tool, even one that runs client-side. For production keys, use OpenSSL or a server-side library. This tool is for development, testing, and learning.
Frequently asked questions
What is the difference between JWK and PEM?
JWK (RFC 7517) is a JSON object with base64url-encoded key parameters, designed for web APIs and JWT. PEM (RFC 7468) is base64-encoded DER (binary ASN.1) wrapped in text headers, designed for config files and OpenSSL. JWK is used in OAuth/OIDC JWKS endpoints. PEM is used in nginx, Apache, and Java. This tool converts between them so you can use the same key in both contexts.
What do the JWK fields n, e, d, p, q, dp, dq, qi mean?
These are RSA key parameters. `n` is the modulus, `e` is the public exponent (usually 65537, encoded as `AQAB`). `d` is the private exponent. `p` and `q` are the prime factors of the modulus. `dp` and `dq` are the CRT exponents (d mod p-1 and d mod q-1). `qi` is the CRT coefficient (q^-1 mod p). These correspond to the PKCS#1 RSAPrivateKey fields. Public RSA JWKs contain only `n` and `e`.
Can this tool convert Ed25519 keys?
Yes. Ed25519 keys use the OKP key type defined in RFC 8037. The JWK contains `kty: OKP`, `crv: Ed25519`, `x` (public key), and optionally `d` (private key). The tool imports them via jose and WebCrypto and can export to PEM PKCS#8 (private) or PEM SPKI (public) with the Ed25519 AlgorithmIdentifier (OID 1.3.101.112).
Why does converting a public key to PKCS#8 fail?
PKCS#8 (RFC 5208) is a private key format. It contains private key material inside an AlgorithmIdentifier wrapper. A public key does not have private material, so exporting it as PKCS#8 is impossible. Use SPKI (SubjectPublicKeyInfo, RFC 5280) for public keys instead. The tool shows an error if you try to export a public key as PKCS#8.
Does the conversion change my key?
No. The conversion preserves the mathematical key material exactly. It only changes the encoding format (JSON vs ASN.1/DER vs base64). Converting from JWK to PEM and back to JWK produces the same JSON object. You can verify this with the Swap button: convert, swap, and confirm the output matches your original input.
Conclusion
JWK is the key format for the JWT ecosystem, but PEM and DER dominate the OpenSSL and Java worlds. This converter bridges them in your browser, handling RSA, EC, Ed25519, and symmetric keys with no data leaving your device. For converting RSA-only keys between PKCS#1, PKCS#8, SPKI, PEM, and DER, use the PEM/DER/PKCS Converter. For a broader format converter that handles non-RSA algorithms, see the Key Format Converter. To generate new JWKs or parse existing ones, try the JWK Generator / Parser. For ECDSA signing and verification, use the Block Cipher tool with WebCrypto.