JWT HS256 vs RS256
HS256 signs and verifies with the same shared secret (HMAC), so anyone who can verify a token can also forge one. RS256 signs with a private key and verifies with the corresponding public key, so verifiers only need the public half and can't forge tokens.
HS256: one secret, two capabilities
HS256 (HMAC-SHA256) uses a single symmetric secret for both signing and verifying.
Any service that can verify an HS256 token necessarily holds the same secret used to sign it, so it could also mint valid tokens for any subject.
This is fine for a single backend that both issues and checks its own tokens, but risky once multiple independently-trusted services need to verify tokens.
RS256: separate signing and verifying keys
RS256 (RSA-SHA256) signs with a private key that only the issuer holds, and verifies with the matching public key, which can be distributed freely (e.g. via a JWKS endpoint).
A verifier with only the public key can confirm authenticity but cannot produce new valid signatures — the trust relationship is one-directional.
Picking one
Single trusted issuer and verifier in the same backend, low key-management overhead desired: HS256 is simpler and cheaper to compute.
Multiple independent services need to verify tokens from a central issuer (microservices, third-party APIs): RS256 (or ES256) avoids distributing a secret that would let any verifier impersonate the issuer.