C++ header-only

Open-source C++ projects categorized as header-only

Top 23 C++ header-only Projects

  • GitHub repo json

    JSON for Modern C++

    Project mention: Send string/vector over sockets | reddit.com/r/cpp_questions | 2021-06-11

    You can use JSON as the intermediate datastructure for serializing and de-serializing (https://github.com/nlohmann/json).

  • GitHub repo Catch

    A modern, C++-native, header-only, test framework for unit-tests, TDD and BDD - using C++11, C++14, C++17 and later (or C++03 on the Catch1.x branch)

    Project mention: Projects that use ctest? | reddit.com/r/cpp_questions | 2021-05-29


  • GitHub repo spdlog

    Fast C++ logging library.

    Project mention: Presenting a C++ project on Github elegantly | reddit.com/r/cpp_questions | 2021-05-07
  • GitHub repo Crow

    Crow is very fast and easy to use C++ micro web framework (inspired by Python Flask)

    Project mention: cpprestsdk in maintenance mode | reddit.com/r/cpp | 2021-06-08

    I haven't used any of the following libraries/frameworks but maybe some of them will fit for your needs: - Crow micro web framework

  • GitHub repo GuiLite

    ✔️The smallest header-only GUI library(4 KLOC) for all platforms

    Project mention: Deeply understand your GitHub/GitLab project | reddit.com/r/github | 2021-01-17

    You can get source code here

  • GitHub repo entt

    Gaming meets modern C++ - a fast and reliable entity component system (ECS) and much more

    Project mention: Understanding ENTT/ECS and cache | reddit.com/r/gamedev | 2021-06-15

    I'm in the process of developing a game using entt to implement ecs, since I've heard that it can help with performance by optimizing memory packing / cache hit rate.

  • GitHub repo GLM

    OpenGL Mathematics (GLM)

    Project mention: SIMD for C++ Developers [pdf] | reddit.com/r/cpp | 2021-04-28

    It seems https://github.com/g-truc/glm also supports SIMD (at least if used / configured correctly).

  • GitHub repo cpp-httplib

    A C++ header-only HTTP/HTTPS server and client library

    Project mention: cpprestsdk in maintenance mode | reddit.com/r/cpp | 2021-06-08

    If you need an embedded C++ HTTP server then there are plenty of libraries/frameworks (in random order): Crow, RESTinio, Boost.Beast, cpp-httplib, http_backend, Pistache, RestBed, served, proxygen, Simple-Web-Server, drogon, oat++.

  • GitHub repo doctest

    The fastest feature-rich C++11/14/17/20 single-header testing framework

    Project mention: Python 3 Types in the Wild: A Tale of Two Type Systems [pdf] | news.ycombinator.com | 2021-04-14

    Even aside from deliberate backwards-compatibility breaks in the standard, compilers sometimes break compatibility. Both MSVC and GCC 11 have changed their header file transitive includes within the past few years, causing projects (like doctest and Qt5) to stop compiling because they forgot to include headers, which built fine in the past but not anymore. IDK if it's "very common", but it's definitely happening in the wild.

    MSVC: https://github.com/onqtam/doctest/issues/183


    - https://invent.kde.org/qt/qt/qtbase/-/commit/8252ef5fc6d0430...

    - https://invent.kde.org/qt/qt/qtbase/-/commit/cb2da673f53815a...

  • GitHub repo Magic Enum C++

    Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate code

    Project mention: I made a new enum implementation for C++ that should simulate stateful enums. Any feedback and improvements is welcome. (Due to macro problems, doesn't work on msvc correctly) | reddit.com/r/cpp | 2021-05-21

    Anyway, have you tried https://github.com/Neargye/magic_enum ? How is you implementation different?

  • GitHub repo compile-time-regular-expressions

    A Compile time PCRE (almost) compatible regular expression matcher.

    Project mention: What can C++ do that Rust can’t? (2021 edition) | reddit.com/r/rust | 2021-05-08

    There is also https://github.com/hanickadot/compile-time-regular-expressions that is written by one of the cpp committee and is meant to be almost as fast burntsushi's regex lib.

  • GitHub repo indicators

    Activity Indicators for Modern C++

    Project mention: It there a library for creating a progress bar? | reddit.com/r/cpp_questions | 2021-03-31

    Maybe this one: https://github.com/p-ranav/indicators

  • GitHub repo FunctionalPlus

    Functional Programming Library for C++. Write concise and readable C++ code.

    Project mention: Why C++ for everything? | reddit.com/r/ROS | 2021-04-28

    As idiomatic, I will try to adopt as much as possible purely functional programming in C++ by using https://github.com/Dobiasd/FunctionalPlus . Do you have by any chance any alternative suggestion?

  • GitHub repo PEGTL

    Parsing Expression Grammar Template Library

    Project mention: Rust's Most Unrecognized Contributor | reddit.com/r/rust | 2021-05-02
  • GitHub repo uvw

    Header-only, event based, tiny and easy to use libuv wrapper in modern C++ - now available as also shared/static library!

  • GitHub repo hana

    Your standard library for metaprogramming

    Project mention: Simple `struct` static reflection system I use that tracks names, attributes (in my own code I also keep `constexpr` hashes of names) -- example gets fully inlined into `main()` | reddit.com/r/cpp | 2021-04-24

    And then there's also the longstanding issue with default member initializers -- https://github.com/boostorg/hana/issues/409 -- which was a deal-breaker.The PROP system avoids this issue precisely by having the macro be as local as possible: the default member initializer is outside the macro. It does this while still letting you attach additional PropAttribs metadata (I'm not sure what additional metadata attachment looks like in Hana? haven't really tried). Default values and additional attributes are by and large quite more important to me in my use cases for reflection (component types in game ECS) than range syntax (everything I've needed and can think of needing is covered by for-each loop).

  • GitHub repo plog

    Portable, simple and extensible C++ logging library

  • GitHub repo Better Enums

    C++ compile-time enum to string, iteration, in a single header file

  • GitHub repo mio

    Cross-platform C++11 header-only library for memory mapped file IO (by mandreyel)

    Project mention: Fastest way to read very large file(Gb to Tb) in C++ | reddit.com/r/cpp | 2021-05-19

    I would memory map it. Use this lib: https://github.com/mandreyel/mio

  • GitHub repo Nameof C++

    Nameof operator for modern C++, simply obtain the name of a variable, type, function, macro, and enum

    Project mention: Getting an Unmangled Type Name at Compile Time | reddit.com/r/cpp | 2021-03-10
  • GitHub repo Argh!

    Argh! A minimalist argument handler. (by adishavit)

  • GitHub repo robin-hood-hashing

    Fast & memory efficient hashtable based on robin hood hashing for C++11/14/17/20

    Project mention: Fast And Memory Efficient C++ Hashtable Based On Robin Hood Hashing | reddit.com/r/programming | 2021-05-23
  • GitHub repo Inja

    A Template Engine for Modern C++

    Project mention: Looking for a codegen library that uses C++ for scripting | reddit.com/r/cpp | 2021-03-10

    I've looked into a newer template engine like Inja, but my client isn't quite happy with that either. Inja allows you to write templates that you feed JSON data into:

NOTE: The open source projects on this list are ordered by number of github stars. The number of mentions indicates repo mentiontions in the last 12 Months or since we started tracking (Dec 2020). The latest post mention was on 2021-06-15.


What are some of the best open-source header-only projects in C++? This list will help you:

Project Stars
1 json 24,838
2 Catch 13,469
3 spdlog 11,796
4 Crow 6,353
5 GuiLite 5,497
6 entt 5,276
7 GLM 5,209
8 cpp-httplib 5,086
9 doctest 3,318
10 Magic Enum C++ 1,916
11 compile-time-regular-expressions 1,905
12 indicators 1,599
13 FunctionalPlus 1,374
14 PEGTL 1,345
15 uvw 1,266
16 hana 1,239
17 plog 1,143
18 Better Enums 1,132
19 mio 1,127
20 Nameof C++ 1,102
21 Argh! 820
22 robin-hood-hashing 807
23 Inja 758