Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
J

jwt-cpp

> 编程语言
Open source

A header only library for creating and validating json web tokens in c++

1.2K stars0 likes0 views
WebsiteGitHub

About

A header only library for creating and validating json web tokens in c++

[![Linux Badge][Linux]][Cross-Platform] [![MacOS Badge][MacOS]][Cross-Platform] [![Windows Badge][Windows]][Cross-Platform] [Linux]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/cross-platform/ubuntu-latest/shields.json [MacOS]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/cross-platform/macos-latest/shields.json [Windows]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/cross-platform/windows-latest/shields.json [Cross-Platform]: https://github.com/Thalhammer/jwt-cpp/actions?query=workflow%3A%22Cross-Platform+CI%22

Overview

A header only library for creating and validating JSON Web Tokens in C++11. For a great introduction, read this.

The objective is to deliver a versatile and universally applicable collection of algorithms, classes, and data structures, fostering adaptability and seamless integration with other libraries that you may already be employing.

Signature algorithms

jwt-cpp comprehensively supports all algorithms specified in the standard. Its modular design facilitates the seamless inclusion of additional algorithms without encountering any complications. Should you wish to contribute new algorithms, feel free to initiate a pull request or open an issue.

For completeness, here is a list of all supported algorithms:

HMSC RSA ECDSA PSS EdDSA
HS256 RS256 ES256 PS256 Ed25519
HS384 RS384 ES384 PS384 Ed448
HS512 RS512 ES512 PS512
ES256K

Getting Started

Installation instructions can be found here.

A simple example is decoding a token and printing all of its claims let's (try it out):

#include 
#include 

int main() {
    std::string const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.eyJpc3MiOiJhdXRoMCIsInNhbXBsZSI6InRlc3QifQ.lQm3N2bVlqt2-1L-FsOjtR6uE-L4E9zJutMWKIe1v1M";
    auto decoded = jwt::decode(token);

    for(auto& e : decoded.get_payload_json())
        std::cout  claim(json::object({{"json", true},{"example", 0}}));

To learn how to writes a trait's implementation, checkout the these instructions

Base64 Options

With regard to the base64 specifications for JWTs, this library includes base.h encompassing all necessary variants. While the library itself offers a proficient base64 implementation, it's worth noting that base64 implementations are widely available, exhibiting diverse performance levels. If you prefer to use your own base64 implementation, you have the option to define JWT_DISABLE_BASE64 to exclude the jwt-cpp implementation.

Contributing

If you have suggestions for improvement or if you've identified a bug, please don't hesitate to open an issue or contribute by creating a pull request. When reporting a bug, provide comprehensive details about your environment, including compiler version and other relevant information, to facilitate issue reproduction. Additionally, if you're introducing a new feature, ensure that you include corresponding test cases to validate its functionality.

Dependencies

In order to use jwt-cpp you need the following tools.

  • libcrypto (openssl or compatible)
  • libssl-dev (for the header files)
  • a compiler supporting at least c++11
  • basic stl support

In order to build the test cases you also need

  • gtest
  • pthread

Troubleshooting

See the FAQs for tips.

Conference Coverage

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++cppheader-onlyjson-web-tokenjwt

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言