C++ single-file

Open-source C++ projects categorized as single-file

Top 16 C++ single-file Projects

single-file
  1. doctest

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

    Project mention: Doctest is a new C++ testing framework | news.ycombinator.com | 2025-07-09
  2. InfluxDB

    InfluxDB – Built for High-Performance Time Series Workloads. InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.

    InfluxDB logo
  3. 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: My Open Source Journey Begins with GitHub & Magic Enum | dev.to | 2025-09-03

    https://github.com/Neargye/magic_enum I chose this project because, while experimenting with enums in my course management project, I realized that I was writing a lot of boilerplate code. I even tried applying generic programming by using the library to avoid meaningless pointers and experimented with templates, but in the end, this approach made the code more complicated than I had thought. In C++, enums are not very flexible by default, it’s not possible to easily iterate through them or convert them to and from strings. This often results in repetitive code and makes programs more prone to errors. With the help of modern C++17 features, however, libraries like magic_enum can make our lives much easier by providing static reflection and avoiding the need for manual stuff. Enums are also a great tool for APIs instead of introducing unnecessary layers of inheritance and polymorphism which could lead to confusion, we can use enums to keep the design simple and clear.

  4. Nameof C++

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

  5. tomlplusplus

    Header-only TOML config file parser and serializer for C++17.

    Project mention: OSD600 Lab 4 | dev.to | 2025-10-03

    I found that this repository had no pull request yet so I contacted the owner to get permission to work on it after filing an issue, then I got to work researching how to approach this using C++. My C++ is rusty, so it took me some time to work my way through the code. Finally, with a little research, I worked out that I could use the existing CMake file in this project to set up the tomlplusplus implementation which would allow me to parse a config.toml file and load default options into the tool. I added a new function, loadFromConfig, that reads the TOML file and populates the CLI options struct with values like output, include, exclude, and recent. This way, users can define their preferences once and avoid repeating long command-line arguments.

  6. nanobench

    Simple, fast, accurate single-header microbenchmarking functionality for C++11/14/17/20

  7. Argh!

    Argh! A minimalist argument handler. (by adishavit)

  8. expected-lite

    expected lite - C++23 expected objects for C++11 and later in a single-file header-only library

  9. Stream

    Stream - Scalable APIs for Chat, Feeds, Moderation, & Video. Stream helps developers build engaging apps that scale to millions with performant and flexible Chat, Feeds, Moderation, and Video APIs and SDKs powered by a global edge network and enterprise-grade infrastructure.

    Stream logo
  10. span-lite

    span lite - A C++20-like span for C++98, C++11 and later in a single-file header-only library

  11. string-view-lite

    string_view lite - A C++17-like string_view for C++98, C++11 and later in a single-file header-only library

  12. semver

    Semantic Versioning for modern C++ (by Neargye)

  13. imgui_entt_entity_editor

    A drop-in entity editor for EnTT with Dear ImGui

  14. serializer

    A single header standard C++ serialization framework. (by eyalz800)

  15. scope_guard

    A modern C++ scope guard that is easy to use but hard to misuse.

  16. ring-span-lite

    ring-span lite - A C++yy-like ring_span type for C++98, C++11 and later in a single-file header-only library

  17. reflect

    A single file header only static reflection library for C++20. (by M-Fatah)

  18. std_net

    std_net.h` is a zero-dependency, header-only C/C++ networking library for TCP sockets. It abstracts cross-platform complexities (Windows/Linux/macOS/Android/FreeBSD) into a unified API for building clients/servers. Features include IPv4/IPv6 support (Happy Eyeballs), blocking/non-blocking I/O, timeouts, and RAII wrappers. MIT licensed.

    Project mention: Show HN: Std_net.h – Single-file cross-platform TCP networking (C/C++) | news.ycombinator.com | 2025-09-09
  19. SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
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).

C++ single-file discussion

C++ single-file related posts

  • Refactoring with C++17 std::optional

    2 projects | /r/cpp | 22 May 2023
  • Is there a std::string::split or something similar?

    2 projects | /r/cpp_questions | 13 Mar 2023
  • The 23 year-old C++ developers with three job offers over $500k

    2 projects | /r/cpp | 22 Apr 2022
  • Nanobench: Fast, Accurate, Single-Header Microbenchmarking Functionality For C++

    2 projects | /r/cpp | 9 Nov 2021
  • C++ Return: std::any, std::optional, or std::variant?

    1 project | /r/cpp | 20 Sep 2021
  • A note from our sponsor - SaaSHub
    www.saashub.com | 23 Dec 2025
    SaaSHub helps you find the best software and product alternatives Learn more →

Index

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

# Project Stars
1 doctest 6,529
2 Magic Enum C++ 5,861
3 Nameof C++ 2,238
4 tomlplusplus 1,939
5 nanobench 1,604
6 Argh! 1,406
7 expected-lite 524
8 span-lite 510
9 string-view-lite 462
10 semver 345
11 imgui_entt_entity_editor 261
12 serializer 198
13 scope_guard 200
14 ring-span-lite 165
15 reflect 16
16 std_net 11

Sponsored
InfluxDB – Built for High-Performance Time Series Workloads
InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.
www.influxdata.com

Did you know that C++ is
the 7th most popular programming language
based on number of references?