Single-file public-domain/open source libraries with minimal dependencies

I am the author of a large number of single-file C/C++ public domain libraries. I am not the only person who writes libraries like this, so below are other, similar libraries.

Generally, the following is a list of small, easy-to-integrate, portable libraries which are usable from C and/or C++, and should be able to be compiled on both 32-bit and 64-bit platforms. However, I have not personally verified that any specific lilbrary is as advertised, or is quality software.


Exceptions will be allowed for good reasons.

Recent additions

Recent additions are marked with an asterisk in the left column.

New libraries and corrections

See discussion after the list.

JSON Parsing

There are a lot of JSON parsers listed here. For some analysis and performance results, check out https://github.com/miloyip/nativejson-benchmark

Other lists

Also you might be interested in other related, but different lists:

Library listing

Public domain single-file libraries usable from C and C++ are in bold. Other libraries are either non-public domain, or two files, or not usable from both C and C++, or all three. Libraries of more than two files are mostly forbidden.

For the API column, "C" means C only, "C++" means C++ only, and "C/C++" means C/C++ usable from either; some files may require building as C or C++ but still qualify as "C/C++" as long as the header file uses extern "C" to make it work. (In some cases, a header-file-only library may compile as both C or C++, but produce an implementation that can only be called from one or the other, because of a lack of use of extern "C"; in this case the table still qualifies it as C/C++, as this is not an obstacle to most users.)



GenannzlibC/C++2simple neural networks (ANN)
KANNMITC/C++2automatic differentiation (2 files)
micropatherzlibC++2pathfinding with A*


Argh!BSDC++1command-line argument parsing
ClaraBoostC++1composable, command line parser for C++ 11 and beyond
CLI11BSDC++1Feature-rich CLI parsing in modern C++11
cmdlineBSDC++1command-line argument parsing
flagspublic domainC++1command-line argument parsing
kgflagsMITC/C++1command-line argument parsing
linkomMITC/C++1command-line argument parsing w/ DOS-style options
optionparserMITC++1command-line argument parsing
pargpublic domainC2command-line argument parsing
ProgramOptions.hxxMITC++1command-line argument parsing


aw_ima.hMITC/C++1IMA-ADPCM audio decoder
btac1cMITC/C++1MS-IMA_ADPCM variant
dr_flacpublic domainC/C++1FLAC audio decoder
dr_wavpublic domainC/C++1WAV audio loader
GenevaMITC/C++1Library generating 8-bit waveforms of various kinds
minimp3CC0C1Minimalistic MP3 decoder with sse/neon support
miniaudiopublic domainC/C++1Audio playback and capture library
pocketmodMITC/C++1ProTracker MOD file renderer
sts_mixerpublic domainC/C++1simple stereo audio mixer
tinysoundzlibC/C++1direct sound audio mixer & WAV loader
TinySoundFontMITC/C++1SoundFont2 loader & synthesizer


dmc_unrarGPLv2+C/C++1RAR file decompression
fastlzMITC/C++2fast but larger LZ compression
lz4BSDC/C++2fast but larger LZ compression
miniz.cMITC/C++1compression, decompression, ZIP file, PNG writing
microtarMITC/C++2lightweight tar library
pithyBSDC/C++2fast but larger LZ compression


Monocypherpublic domainC2high-quality small cryptography library
TweetNaClpublic domainC2high-quality tiny cryptography library

data structures

avlpublic domainC/C++2AVL tree
c-bool-valueWTFPLv2C/C++1Simple and easy boolean values in standard c
chobo-shlMITC++1several C++11 standard contaner like libraries and helpers
DG_dynarr.hpublic domainC/C++1typesafe dynamic arrays (like std::vector) for plain C
DynaVarGPL-3.0C++1Object which can store any type of primitive data type
klibMITC/C++2many 2-file libs: hash, sort, b-tree, etc
libpqueueBSDC/C++2priority queue (heap)
minilibspublic domainC2two-file binary tress (also regex, etc)
PackedArrayWTFPLv2C2memory-efficient array of elements with non-pow2 bitcount
selistISCC/C++2space-efficient linked-list
mempoolMITC++1Efficient minimal memory pool implementation for C++
uthashBSDC/C++2several 1-header, 1-license-file libs: generic hash, list, etc


dbgtoolszlibC/C++2cross-platform debug util libraries
debug-assertzlibC++1modular assertion macro
debugbreakBSDC/C++1programmatic debug break
logurupublic domainC++1flexible logging
pempek_assert.cppWTFPLv2C++2flexible assertions

files & filenames

DG_misc.hpublic domainC/C++1Daniel Gibson's stb.h-esque cross-platform helpers: path/file, strings
direntMITC/C++1dirent for Windows: retrieve file & dir info
tfileMITC++1FILE* wrapper does read-write-append-seek-close (Win/Mac/Unix)
TinyDirBSDC1cross-platform directory reading (Win/POSIX/MinGW)
tinyfileszlibC/C++1cross-platform directory reading (Win/Mac/Unix)
whereamiWTFPLv2C/C++2get path/filename of executable or module

geometry file

cgltfMITC1glTF 2.0 file loader
fast_obj.hMITC1wavefront OBJ file loader
objzeroMITC2wavefront OBJ file loader
tinyplypublic domainC++2PLY mesh file loader
tinyobjloaderMITC++1wavefront OBJ file loader
tinyobjloader-cMITC1wavefront OBJ file loader
tk_objfileMITC/C++1OBJ file loader
yocto_obj.hMITC/C++1wavefront OBJ file loader

geometry math

ClipperBoostC++2line & polygon clipping & offsetting
dfpublic domainC/C++1find voronoi region in linear time of size of lattice
jc_voronoiMITC/C++1find voronoi regions on float/double data
nanoflannBSDC++1build KD trees for point clouds
nv_voronoi.hpublic domainC/C++1find voronoi regions on lattice w/ integer inputs
par_msquaresMITC/C++1convert (binarized) image to triangles
par_shapesMITC/C++1generate various 3d geometric shapes
PolyPartitionMITC++2polygon triangulation, partitioning
rjm_mc.hpublic domainC/C++1marching cubes triangulator
sobol.hpublic domainC/C++1sobol & stratified sampling sequences
sdf.hMITC/C++1compute signed-distance field from antialiased image
Tomas Akenine-Moller snippetspublic domainC/C++2various 3D intersection calculations, not lib-ified
VoxelizerMITC/C++1convert triangle mesh to voxel triangle mesh
xatlasMITC++2mesh parameterization
yocto_bvh.hMITC/C++1ray-casting and closest-element queries of bounding-volume hierarchy
yocto_shape.hMITC/C++1shape generation, tesselation, normals, etc.

graphics (text)

rangpublic domainC++1cross-platform colored console text

graphics (2d)

blendishMITC/C++1blender-style widget rendering using NanoVG
CimgCeCILL/CeCILL-CC++1image processing toolkit (60K LoC)
Immediate2Dpublic domainC++2zero-configuration, immediate-mode 2D graphics for Windows
noc_turtleMITC/C++2procedural graphics generator
tigrpublic domainC/C++2quick-n-dirty window text/graphics for Windows and macOS

graphics (3d)

debug-drawpublic domainC++1API-agnostic immediate-mode debug rendering
lightmapperpublic domainC/C++1use your OpenGL renderer to offline bake lightmaps
mikktspacezlibC/C++2compute tangent space for normal mapping
rjm_raytrace.hpublic domainC/C++1minimalistic SSE packet raytracer for offline baking
seamoptimizerpublic domainC/C++1modify lightmap data to hide seams
sokol_gfx.hMITC/C++1cross-platform 3D API wrapper (GLES2+3/GL3/D3D11/Metal)
Swarmzpublic domainC++1swarming/flocking algorithm
tinygizmopublic domainC++2gizmo objects for interactively editing 3d transformations
Vertex Cache Optimizerpublic domainC/C++1vertex cache optimization of meshes
Vulkan Memory AllocatorMITC/C++1memory allocator for Vulkan
yocto_trace.hMITC/C++1physically-based unidirectional path tracer w/ MIS for direct lights
yocto_symrigid.hMITC/C++1rigid body simulator (sequential impulse/PGS) with support for concave objects


EasyTabpublic domainC/C++1multi-platform tablet input
libueMITC/C++1Helper library for Linux device hot-plug event


xxHashBSDC/C++2fast hash function


EXR miniexrpublic domainC++2OpenEXR writer, needs header file
EXR tinyexrBSDC/C++1EXR image read/write, uses miniz internally
GIF gif.hpublic domainC++1animated GIF writer (can only include once)
GIF gif_loadpublic domainC/C++1(animated) GIF reader
GIF jo_gif.cpppublic domainC++1animated GIF writer (CPP file can also be used as H file)
JPG jpeg-compressorpublic domainC++22-file JPEG compress, 2-file JPEG decompress
JPG tiny_jpeg.hpublic domainC/C++1JPEG encoder
JPG EXIF easyexifMITC++2EXIF metadata extractor for JPEG images
JPG EXIF TinyEXIFBSDC++2Parse EXIF data from JPEG (XMP w/ TinyXML2 lib)
PDF PDFgenpublic domainC2PDF writer
PNG lodepngzlibC/C++2PNG encoder/decoder
PNG picopng.cppzlibC++2tiny PNG loader
PNG TinyPngOutputLGPLv3C/C++2PNG writer
PNM PNMApache 2.0C++1PBM, PGM and PPM reader and writer
SVG nanoSVGzlibC/C++11-file SVG parser; 1-file SVG rasterizer
cro_mipmap.hpublic domainC/C++1average, min, max mipmap generators
rjm_texbleed.hpublic domainC/C++1Fills in the color of pixels where alpha==0


amoebaMITC/C++1constraint solver (Cassowary) w/Lua binding
fftpublic domainC++1Fast Fourier Transform
PoissonGenerator.hMITC++1Poisson disk points generator (disk or rect)
prns.hpublic domainC/C++1seekable pseudo-random number sequences
rnd.hpublic domainC/C++1pseudo-random number generation
ShaderFastLibsMITC++1(also HLSL) approximate transcendental functions optimized for shaders (esp. GCN)
simrank.hppMITC++2SimRank graph similarity algorithm
SummedAreaTableMITC++1Summed-Area Table generation and sum/avg queries
TinyExprzlibC2evaluation of math expressions from strings


bikeshed.hMITC/C++1cross-platform lock free fixed memory hierarchical work scheduler
mm_sched.hzlibC/C++1cross-platform multithreaded task scheduler based on enkiTS
thread.hpublic domainC/C++1cross-platform thread primitives
TinyCThreadzlibC/C++2cross-platform implementation of the C11 Threads API
TinyThread++zlibC++2cross-platform implementation of the C++11 Threads API


civetwebMITC/C++2HTTP server, fork of Mongoose
happyhttpzlibC++2HTTP client requests
httppublic domainC/C++1HTTP get/post
libcluonMPL-2.0C++1cross-platform socket wrapper and data marshalling with native implementations for Protobuf, LCM/ZCM, JSON, and MsgPack serialization/deserialization
LUrlParserMITC++2lightweight URL & URI parser RFC 1738, RFC 3986
mm_web.hBSDC/C++1lightweight webserver, fork of webby
mongooseGPLv2C/C++2HTTP server
par_easycurl.hMITC/C++1cURL wrapper
sts_netpublic domainC/C++1cross-platform socket wrapper (socket sets and packet API)
yoctopublic domainC/C++2non-production-use HTTP server
zed_netpublic domainC/C++1cross-platform socket wrapper
znetMITC/C++1cross-platform networking w/ Lua binding


archivepublic domainC++1binary serialize & deserlize w/ STL support
libcluonMPL-2.0C++1cross-platform data serialization/deserialization with native implementations for Protobuf, LCM/ZCM, JSON, and MsgPack


ajsonBoostC++1JSON serialize & deserialize w/ STL support
json.hpublic domainC/C++2JSON parser
json.hppMITC++1JSON parse, serialize, deserialize
jzon.hMITC++2JSON parser
PicoJSONBSDC++1JSON parse/serializer
parsonMITC/C++2JSON parser and serializer


mini-yamlMITC++2YAML parser and serializer


CSVstreamMITC++1CSV parser
Fast C++ CSV ParserBSDC++1CSV parser
RapidcsvBSDC++1CSV parser
Vince's CSV ParserMITC++1CSV parser and serializer


cmpMITC/C++2MessagePack parser and serializer
inihBSDC/C++2.ini file parser
ini.hpublic domainC/C++1.ini file parser
minilibspublic domainC2two-file regex (also binary tree, etc)
mm_lexer.hzlibC/C++1C-esque language lexer
SLREGPLv2C/C++1regular expression matcher
tinymemfilezlibC++1fscanf on in-memory files


MicroProfilepublic domainC++2-4CPU (and GPU?) profiler, 1-3 header files, uses miniz internally
profMITC/C++1profiler for Linux
RemoteryApache 2.0C/C++2CPU/GPU profiler Win/Mac/Linux, using web browser for viewer


DuktapeMITC2embeddable JavaScript engine
MY-BASICMITC2interpreter for a BASIC dialect scripting language
LILzlibC/C++2interpreter for a Tcl-like scripting language
lualiteMITC++1generate Lua bindings in C++
PicolBSDC/C++1interpreter for a Tcl-like scripting language
s7BSDC/C++2interpreter for a subset of Scheme (R5RS/R7RS)


dfaMITC/C++2fast UTF-8 decoder (need a header file)
DG_misc.hpublic domainC/C++1Daniel Gibson's stb.h-esque cross-platform helpers: path/file, strings
gb_string.hpublic domainC/C++1dynamic strings
Obfuscatepublic domainC++1Guaranteed compile-time string literal obfuscation library for C++14
inja.hppMITC++1template engine
strpool.hpublic domainC/C++1string interning
str_view.hppMITC++1null-termination-aware string-view class
utf8public domainC/C++1UTF-8 string library

unit testing

catchBoostC++1unit testing
catch2BoostC++1unit testing
doctestMITC++1unit testing
fctxBSDC/C++1unit testing
greatestiSCC1unit testing
hippomocksLGPLC++1unit testing
labratpublic domainC/C++1unit testing
minctestzlibC1unit testing
munitMITC1unit testing
SPUTBSDC/C++1unit testing
trompeloeilBoostC++1unit testing
utestMITC/C++1unit testing
utest.hpublic domainC/C++1unit testing

user interface

dear imguiMITC++9an immediate-mode GUI formerly named "ImGui"; 3rd-party C wrapper
libcmdfpublic domainC1a small library for writing CLI applications
linenoiseBSDC/C++2terminal readline w/ history etc
noc_file_dialog.hMITC/C++1file open/save dialogs (Win/Mac/Linux)
nuklearpublic domainC/C++1minimal GUI toolkit
tinyfiledialogsZLIBC/C++2modal dialogs inc. file open/save (Win/Mac/Linux)
wcwidth9Apache 2.0C1platform independent wcwidth with full unicode 9 support


algebra3.hpublic domainC++1vector utilities for 2, 3, and 4 element vectors, all inline
ccVector.hpublic domainC/C++1Vector, quaternion and matrix math
gb_mathpublic domainC/C++1Vector, quaternion and matrix math w/o math.h
Handmade Mathpublic domainC/C++1vector math
linalg.hpublic domainC++1vector/matrix/quaternion math
linalgISCC/C++1vector/matrix/quaternion math
mm_vec.hBSDC/C++1SIMD vector math


jo_mpegpublic domainC++1MPEG file writer


app.hpublic domainC/C++1Windows-only-but-meant-to-be-cross-platform game-ish framework


ASAPMITC++1library for parsing, printing, iterating and operating on dates.
cpp-generatorsBSDC++1generators in C++
Hedleypublic domainC/C++1compiler portability, optimization, static analysis, etc.
levenshteinMITC/C++2compute edit distance between two strings
MakeID.hpublic domainC++1allocate/deallocate small integer IDs efficiently
PlusCallbackzlibC++1function/method callbacks
process.hpublic domainC/C++1process control API
randomMITC++1convenient API for random
sokol_time.hMITC/C++1cross-platform time measurement
stmrMITC2extract English word stems
tinyformatBoostC++1typesafe printf
tinytimezlibC/C++1quick-and-dirty time elapsed time
visit_structBoostC++2struct-field reflection

There are also these XML libraries, but I am so significantly not a fan of XML that I've consigned these to the basement to make you think twice.

New libraries and corrections

Submissions of new libraries: I accept submissions (as issues or as pull requests). Please note that every file that must be included in a user's project counts; a header and a source file is 2 files, but a header file, source file, and LICENSE (if the license isn't in the source file) is 3 files, and won't be accepted, because it's not 2 files. But actually 'LICENSE' is a problem for just dropping the library in a source tree anyway, since it's not scoped to just the library, so library authors are encouraged to include the license in the source file and not require a separate LICENSE.

Corrections: if information for a library above is wrong, please send a correction as an issue, pull request, or email. Note that if the list indicates a library works from both C/C++, but it doesn't, this could be an error in the list or it could be a bug in the library. If you find a library doesn't work in 32-bit or 64-bit, the library should be removed from this list, unless it's a bug in the library.

List FAQ

Can I link directly to this list?

Yes. This is the preferred link.

Why isn't library XXX which is made of 3 or more files on this list?

I draw the line arbitrarily at 2 files at most. (Note that some libraries that appear to be two files require a separate LICENSE file, which made me leave them out). Some of these libraries are still easy to drop into your project and build, so you might still be ok with them. But since people come to stb for single-file public domain libraries, I feel that starts to get too far from what we do here.

Why isn't library XXX which is at most two files and has minimal other dependencies on this list?

Probably because I don't know about it, feel free to submit a pull request, issue, email, or tweet it at me (it can be your own library or somebody else's). But I might not include it for various other reasons, including subtleties of what is 'minimal other dependencies' and subtleties about what is 'lightweight'.

Why isn't SQLite's amalgamated build on this list?

Come on.