5 Facts About JWK: The JSON Format That Carries Keys

JWK explained in plain terms means understanding the JSON format that carries cryptographic keys across the web, a small document that lets a server publish the key a token was signed with. The central question is why keys need a format at all when they are just numbers, and the answer is that a key without labels is unusable, so JWK wraps the numbers in names a verifier can read.

JWK stands for JSON Web Key, defined in RFC 7517, and it represents a key as a JSON object with members like kty for the key type and kid for the key identifier. It covers RSA, elliptic curve, octet and OKP keys, which means one format describes every key a web service needs, and because the format is JSON, any language can parse it.

This article sets out five facts about JWK, what it is, how it works, and where it runs in the real world.

Key takeaways

  • A JWK is a JSON object that represents one key.
  • RFC 7517 defines the format.
  • The kty member names the key type.
  • A JWK Set groups keys under one document.
  • Rotation works by adding keys and changing the kid.

What a JWK is

A JWK is a key written as JSON, and that plain format is what makes it unusual among key formats. Each key is a set of named members with base64url values, which means a public key can be read by any program, and because the format is text, a key can travel in an API response or a web page.

Its signature feature is the kty member. Most key formats bury the algorithm inside the bytes, but a JWK states its type up front as RSA, EC, oct or OKP, which means a verifier knows at a glance which maths to use, and because the type is explicit, a parser can skip a key it does not understand.

The format was a reaction to ad-hoc key exchange. Web services kept inventing their own ways to publish signing keys, so the JOSE working group asked whether one JSON shape could carry them all, because a verifier that must guess the format cannot verify anything, and that practicality is what made JWK worth defining.

It became one of the best-known key formats in the world, and it is named in every discussion of the field. RFC 7517 was published in 2015 alongside the JWT standards, RFC 7518 defines the RSA, EC and oct key members, RFC 8037 added OKP keys for Ed25519, and it is still the first example engineers meet when they learn that keys can be JSON, which means the format survives as a standard even though it is a decade old.

Our guide to WebAuthn explains the login API whose keys are often published as JWKs, and our guide to digital signatures explains the signing a JWK makes verifiable.

How a JWK works

Everything starts with the key type, which sets the shape. A JWK declares its kty first, and the other members follow from it, which means an RSA key carries n and e while an EC key carries crv, x and y, and because the shape follows the type, a parser can validate the key before using it.

Each step begins with the key identifier, which names the key. A JWK carries a kid, a free-form string that a token header can point at, which means a verifier can pick the right key from a set, and because the kid is just a label, rotating a key means publishing a new kid.

The key set is what makes the design work as a whole. A JWK Set is a JSON object with a keys array holding several JWKs, which means a service can publish its current and next keys together, and because the set is fetched from a well-known URL, verifiers can refresh it without new configuration.

The use member spreads the effect further. A JWK can declare use as sig for signing or enc for encryption, which means a key meant for one job is never used for the other, and because the declaration is in the key itself, a verifier can refuse a key used the wrong way.

The rotation is what turns the format into a living system. A signer adds a new key to its set, starts signing with it, and removes the old key later, which means verifiers that refetch the set keep working, and because the kid changes with the key, no token is ever verified against the wrong one.

The result comes from the lookup, read out as a verified token or a rejection. A verifier reads the token header, finds the matching kid in the set, and checks the signature, which means the result is a clear yes or no whatever the service, and that clarity is exactly what token verification needs.

A dark developer desk with a laptop showing a key document on screen, a security key and a notebook beside it
A dark developer desk with a laptop showing a key document on screen, a security key and a notebook beside it, shows how a JWK works: key members take turns being read and matched, step after step, until a token is verified.

Comparing JWK with other key formats

A JWK is one of several ways to carry a key, and each was built with a different emphasis. PEM is the classic text format built for files and certificates, a raw key is the bare bytes built for code, and JWK is the one built to publish keys as JSON, while each approach trades something for something else.

The table below sets out the main contrasts between the leading approaches.

Aspect JWK PEM Raw bytes
Format JSON object Base64 text block Binary
Key type Named by kty Named by header Implied
Key identifier kid member None None
Sets Built in Manual Manual
Best for Web token verification Certificates Embedded code

The practical result is that a JWK is the right choice for web token verification, PEM suits certificates, and raw bytes fit embedded code instead.

Where JWK is used

Identity providers use it to publish signing keys. Google and Microsoft serve their keys as JWK Sets, because every relying party needs the current key, and that need is the reason JWK earns its keep in identity code.

OpenID Connect uses it inside discovery. A provider lists its jwks_uri in its discovery document, because a client must find the keys without being told, and that automation is the reason the design was built for real logins.

API gateways use it to verify tokens. A gateway fetches the set once and caches it by kid, because a token check must be fast, and that speed is the reason JWK appears in gateways far beyond its identity origins.

Benchmarking uses it as the key-format reference. Engineers still quote JWK when they discuss how keys should be published, because it is the clearest example of labels making keys usable, and that number shapes how new formats are measured.

Teaching uses it as the JSON example. Courses introduce JWK when they explain that a key is data too, because it is the clearest case of a format carrying its own description, and a student who understands JWK understands why a key without metadata is a key nobody can use.

Strengths and limits

The greatest strength of a JWK is that it makes keys self-describing. A key that names its own type and identifier can be published, rotated and verified without side channels, and that strength is real, measured in the providers that serve it and confirmed by the verifiers that consume it.

It is also a strength that the format is plain JSON. A key document any language can parse is easy to serve and easy to cache, and that simplicity is worth more than cleverness in a field where a key format that needs a special parser is a format nobody adopts.

The limits are real, though, and the biggest is that a JWK is only a container. It says nothing about whether the key is trustworthy, which means a key served over plain HTTP can be swapped by an attacker, and a system that needs trust must fetch its sets over TLS from a known issuer.

JWK checklist

  • Use JWK for publishing keys, never as proof of trust by itself.
  • Remember RFC 7517 defines the format.
  • Note kty names the type: RSA, EC, oct or OKP.
  • Compare it with PEM to see two kinds of key text.
  • Study the kid, which is what makes rotation work.
  • Check the set, since a stale cache misses new keys.
  • Keep key fetches behind TLS from a known issuer.
  • Read RFC 7518 to see how the key members were set.
  • Choose JWK when web services must publish their keys.

Frequently asked questions

What is a JWK in simple terms?

It is a JSON object that represents a cryptographic key, with named members for its type, identifier and key material.

Who defined JWK?

The IETF JOSE working group, which published RFC 7517 in 2015 alongside the JWT standards.

How is a JWK different from PEM?

Both carry keys as text, but a JWK is JSON with named members and built-in sets, while PEM is a base64 block with a header line.

Is a JWK still secure?

It is a standard format, but it only carries keys, so it must be fetched over TLS from a trusted issuer to mean anything.

Where are JWKs used?

In identity providers, in OpenID Connect discovery, in API gateways, and in teaching about key formats.

When should I use a JWK?

When you publish signing keys for tokens, when you verify JWTs, or when you study web key formats.

The bottom line

JWK explained in one line is this: a key that introduces itself, a 2015 format that wrapped cryptographic keys in JSON and taught the field that a key without labels is a key nobody can use.

It is proof that metadata is half the format, and the reason it still matters is that every key published since has been judged partly by the lesson JWK taught.

This article is general information about how JWK works, not advice about choosing encryption for a particular device or system.

Latest articles

Scroll to Top