{"id":20487918,"url":"https://github.com/thalhammer/jwt-cpp","last_synced_at":"2026-02-09T06:20:10.213Z","repository":{"id":37904108,"uuid":"108908685","full_name":"Thalhammer/jwt-cpp","owner":"Thalhammer","description":"A header only library for creating and validating json web tokens in c++","archived":false,"fork":false,"pushed_at":"2025-03-10T05:00:56.000Z","size":1274,"stargazers_count":966,"open_issues_count":36,"forks_count":260,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-04-13T03:58:35.036Z","etag":null,"topics":["cpp","header-only","json-web-token","jwt"],"latest_commit_sha":null,"homepage":"https://thalhammer.github.io/jwt-cpp/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Thalhammer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["Thalhammer"],"patreon":"Thalhammer"}},"created_at":"2017-10-30T21:08:08.000Z","updated_at":"2025-04-10T15:34:10.000Z","dependencies_parsed_at":"2024-03-31T04:23:46.995Z","dependency_job_id":"6a477226-7233-4094-b2e4-1d63396d6245","html_url":"https://github.com/Thalhammer/jwt-cpp","commit_stats":{"total_commits":342,"total_committers":48,"mean_commits":7.125,"dds":0.368421052631579,"last_synced_commit":"71c3d36507183ceb74b9cf10d1232fe1223bdfb0"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thalhammer%2Fjwt-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thalhammer%2Fjwt-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thalhammer%2Fjwt-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thalhammer%2Fjwt-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Thalhammer","download_url":"https://codeload.github.com/Thalhammer/jwt-cpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248661706,"owners_count":21141450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","header-only","json-web-token","jwt"],"created_at":"2024-11-15T16:53:24.646Z","updated_at":"2026-02-09T06:20:10.176Z","avatar_url":"https://github.com/Thalhammer.png","language":"C++","readme":"\u003cimg src=\"https://raw.githubusercontent.com/Thalhammer/jwt-cpp/master/.github/logo.svg\" alt=\"logo\" width=\"100%\"\u003e\n\n[![License Badge](https://img.shields.io/github/license/Thalhammer/jwt-cpp)](https://github.com/Thalhammer/jwt-cpp/blob/master/LICENSE)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/5f7055e294744901991fd0a1620b231d)](https://app.codacy.com/gh/Thalhammer/jwt-cpp/dashboard)\n[![Linux Badge][Linux]][Cross-Platform]\n[![MacOS Badge][MacOS]][Cross-Platform]\n[![Windows Badge][Windows]][Cross-Platform]\n[![Coverage Status](https://coveralls.io/repos/github/Thalhammer/jwt-cpp/badge.svg?branch=master)](https://coveralls.io/github/Thalhammer/jwt-cpp?branch=master)\n\n[![Documentation Badge](https://img.shields.io/badge/Documentation-master-blue)](https://thalhammer.github.io/jwt-cpp/)\n\n[![Stars Badge](https://img.shields.io/github/stars/Thalhammer/jwt-cpp?style=flat)](https://github.com/Thalhammer/jwt-cpp/stargazers)\n[![GitHub release (latest SemVer including pre-releases)](https://img.shields.io/github/v/release/Thalhammer/jwt-cpp?include_prereleases)](https://github.com/Thalhammer/jwt-cpp/releases)\n[![ConanCenter package](https://repology.org/badge/version-for-repo/conancenter/jwt-cpp.svg)](https://repology.org/project/jwt-cpp/versions)\n[![Vcpkg package](https://repology.org/badge/version-for-repo/vcpkg/jwt-cpp.svg)](https://repology.org/project/jwt-cpp/versions)\n\n[Linux]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/cross-platform/ubuntu-latest/shields.json\n[MacOS]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/cross-platform/macos-latest/shields.json\n[Windows]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Thalhammer/jwt-cpp/badges/cross-platform/windows-latest/shields.json\n[Cross-Platform]: https://github.com/Thalhammer/jwt-cpp/actions?query=workflow%3A%22Cross-Platform+CI%22\n\n## Overview\n\nA header only library for creating and validating [JSON Web Tokens](https://tools.ietf.org/html/rfc7519) in C++11. For a great introduction, [read this](https://jwt.io/introduction/).\n\nThe 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.\n\n## Signature algorithms\n\njwt-cpp comprehensively supports all algorithms specified in the standard. Its modular design facilitates the seamless [inclusion of additional algorithms](docs/signing.md#custom-signature-algorithms) without encountering any complications. Should you wish to contribute new algorithms, feel free to initiate a pull request or [open an issue](https://github.com/Thalhammer/jwt-cpp/issues/new).\n\nFor completeness, here is a list of all supported algorithms:\n\n| HMSC  | RSA   | ECDSA  | PSS   | EdDSA   |\n| ----- | ----- | ------ | ----- | ------- |\n| HS256 | RS256 | ES256  | PS256 | Ed25519 |\n| HS384 | RS384 | ES384  | PS384 | Ed448   |\n| HS512 | RS512 | ES512  | PS512 |         |\n|       |       | ES256K |       |         |\n\n## Getting Started\n\nInstallation instructions can be found [here](docs/install.md).\n\nA simple example is decoding a token and printing all of its [claims](https://tools.ietf.org/html/rfc7519#section-4) let's ([try it out](https://jwt.io/#debugger-io?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.eyJpc3MiOiJhdXRoMCIsInNhbXBsZSI6InRlc3QifQ.lQm3N2bVlqt2-1L-FsOjtR6uE-L4E9zJutMWKIe1v1M)):\n\n```cpp\n#include \u003cjwt-cpp/jwt.h\u003e\n#include \u003ciostream\u003e\n\nint main() {\n    std::string const token = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.eyJpc3MiOiJhdXRoMCIsInNhbXBsZSI6InRlc3QifQ.lQm3N2bVlqt2-1L-FsOjtR6uE-L4E9zJutMWKIe1v1M\";\n    auto decoded = jwt::decode(token);\n\n    for(auto\u0026 e : decoded.get_payload_json())\n        std::cout \u003c\u003c e.first \u003c\u003c \" = \" \u003c\u003c e.second \u003c\u003c '\\n';\n}\n```\n\nYou can build and run [this example](example/print-claims.cpp) locally after cloning the repository.\nRunning some commands, we can see the contents of the [JWT payload](https://datatracker.ietf.org/doc/html/rfc7519#section-3)\n\n```sh\ncmake .\ncmake --build . --target print-claims\n./print-claims\n# iss = \"auth0\"\n# sample = \"test\"\n```\n\nYou'll very quickly notice JWT are not encrypted but rather cryptographically signed to\nprovide [non-repudiation](https://csrc.nist.gov/glossary/term/non_repudiation).\n\nIn order to verify a token you first build a verifier and use it to verify a decoded token.\n\n```cpp\nauto verifier = jwt::verify()\n    .with_issuer(\"auth0\")\n    .with_claim(\"sample\", jwt::claim(std::string(\"test\")))\n    .allow_algorithm(jwt::algorithm::hs256{\"secret\"});\n\nverifier.verify(decoded_token);\n```\n\nThe verifier is stateless so you can reuse it for different tokens.\n\nCreating the token above (and signing it) is equally as easy.\n\n```cpp\nauto token = jwt::create()\n    .set_type(\"JWS\")\n    .set_issuer(\"auth0\")\n    .set_payload_claim(\"sample\", jwt::claim(std::string(\"test\")))\n    .sign(jwt::algorithm::hs256{\"secret\"});\n```\n\nIf you are looking to issue or verify more unique tokens, checkout out the [examples](https://github.com/Thalhammer/jwt-cpp/tree/master/example) working with RSA public and private keys, elliptic curve tokens, and much more!\n\n### Configuration Options\n\nBuilding on the goal of providing flexibility.\n\n#### SSL Compatibility\n\njwt-cpp supports [OpenSSL](https://github.com/openssl/openssl), [LibreSSL](https://github.com/libressl-portable/portable), and [wolfSSL](https://github.com/wolfSSL/wolfssl). For a listed of tested versions, check [this page](docs/ssl.md) for more details.\n\n#### JSON Implementation\n\nThere is no strict reliance on a specific JSON library in this context. Instead, the jwt-cpp utilizes a generic `jwt::basic_claim` that is templated based on type trait. This trait provides the semantic [JSON types](https://json-schema.org/understanding-json-schema/reference/type.html) for values, objects, arrays, strings, numbers, integers, and booleans, along with methods to seamlessly translate between them.\n\nThis design offers flexibility in choosing the JSON library that best suits your needs. To leverage one of the provided JSON traits, refer to [docs/traits.md](docs/traits.md#selecting-a-json-library) for detailed guidance.\n\n##### Providing your own JSON Traits\n\n```cpp\njwt::basic_claim\u003cmy_favorite_json_library_traits\u003e claim(json::object({{\"json\", true},{\"example\", 0}}));\n```\n\nTo learn how to writes a trait's implementation, checkout the [these instructions](docs/traits.md#providing-your-own-json-traits)\n\n#### Base64 Options\n\nWith 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.\n\n## Contributing\n\nIf you have suggestions for improvement or if you've identified a bug, please don't hesitate to [open an issue](https://github.com/Thalhammer/jwt-cpp/issues/new) 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.\n\n### Dependencies\n\nIn order to use jwt-cpp you need the following tools.\n\n* libcrypto (openssl or compatible)\n* libssl-dev (for the header files)\n* a compiler supporting at least c++11\n* basic stl support\n\nIn order to build the test cases you also need\n\n* gtest\n* pthread\n\n## Troubleshooting\n\nSee the [FAQs](docs/faqs.md) for tips.\n\n## Conference Coverage\n\n[![CppCon](https://img.youtube.com/vi/Oq4NW5idmiI/0.jpg)](https://www.youtube.com/watch?v=Oq4NW5idmiI)\n","funding_links":["https://github.com/sponsors/Thalhammer","https://patreon.com/Thalhammer"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthalhammer%2Fjwt-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthalhammer%2Fjwt-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthalhammer%2Fjwt-cpp/lists"}