One-file Libraries

Single-File Libraries

A collection of single-file libraries (header files) that I’ve ran into over the years.
See also list of single-file libs curated by stb.

Not Yet Organized

Library Description
DG_dynarray Dynamics arrays in C
nuklear.h GUI library
webview cross-platform webview library for C/C++/Go
HandmadeMath.h A simple math library for games and computer graphics.
minimp3 Minimalistic MP3 decoder single header library
the-debuginator A juicy feature-packed debug menu intended for games.
the-entitytainer A single header library for managing game entity hierarchies.
jc_voronoi.h A C implementation for creating 2D voronoi diagrams
pcg_basic PCG – Minimal C Implementation
open simplex noise in c Port of Kurt Spencer’s java implementation of open simplex noise to C – Note: This is NOT Ken Perlin’s Simplex noise algorithm.
sdf.h Signed Distance Field Builder for Contour Texturing
gif_load.h A slim, fast and header-only GIF loader written in C
vec_math.h Single-header primitive vector math library
libcmdf A small library for writing CLI applications in C
simple_obj.h A very simple Wavefront .obj loader with glut support.


single-file public domain (or MIT licensed) libraries for C/C++

Most libraries by stb, except: stb_dxt by Fabian “ryg” Giesen, stb_image_resize
by Jorge L. “VinoBS” Rodriguez, and stb_sprintf by Jeff Roberts.

library lastest version category LoC description
stb_vorbis.c 1.14 audio 5462 decode ogg vorbis files from file/memory to float/16-bit signed output
stb_image.h 2.19 graphics 7462 image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC
stb_truetype.h 1.19 graphics 4853 parse, decode, and rasterize characters from truetype fonts
stb_image_write.h 1.09 graphics 1568 image writing to disk: PNG, TGA, BMP
stb_image_resize.h 0.95 graphics 2627 resize images larger/smaller with good quality
stb_rect_pack.h 0.11 graphics 624 simple 2D rectangle packer with decent quality
stb_sprintf.h 1.05 utility 1833 fast sprintf, snprintf for C/C++
stretchy_buffer.h 1.03 utility 262 typesafe dynamic array for C (i.e. approximation to vector<>), doesn’t compile as C++
stb_textedit.h 1.12 user interface 1404 guts of a text editor for games etc implementing them from scratch
stb_voxel_render.h 0.85 3D graphics 3803 Minecraft-esque voxel rendering “engine” with many more features
stb_dxt.h 1.08b 3D graphics 728 Fabian “ryg” Giesen’s real-time DXT compressor
stb_perlin.h 0.3 3D graphics 316 revised Perlin noise (3D input, 1D output)
stb_easy_font.h 1.0 3D graphics 303 quick-and-dirty easy-to-deploy bitmap font for printing frame rate, etc
stb_tilemap_editor.h 0.38 game dev 4172 embeddable tilemap editor
stb_herringbone_wa… 0.6 game dev 1220 herringbone Wang tile map generator
stb_c_lexer.h 0.09 parsing 962 simplify writing parsers for C-like languages
stb_divide.h 0.91 math 419 more useful 32-bit modulus e.g. “euclidean divide”
stb_connected_comp… 0.95 misc 1045 incrementally compute reachability on grids
stb.h 2.31 misc 14405 helper functions for C, mostly redundant in C++; basically author’s personal stuff
stb_leakcheck.h 0.4 misc 186 quick-and-dirty malloc/free leak-checking


Single-file C libraries under the MIT license. Documentation can be found at the top of each header file, but some libraries have an accompanying blog post.

library description link
par_msquares.h efficient marching squares implementation blog post
par_shapes.h generate parametric surfaces and other simple shapes blog post
par_bubbles.h pack circles into hierarchical diagrams blog post
par_bluenoise.h generate progressive 2D point sequences blog post
par_sprune.h efficient broad-phase collision detection in 2D web demo
par_easycurl.h simple HTTP requests using libcurl
par_filecache.h LRU caching on your device’s filesystem
par_easings.h Robert Penner’s easing functions


Various single-file cross-platform C/C++ headers implementing self-contianed libraries.

library description latest version language(s) license
tinyc2 2D collision detection routines on primitives, boolean results and/or manifold generation 1.03 C/C++ zlib
tinysound Load/play/loop/pitch/pan WAV + OGG (stb_vorbis wrapper for OGG) in mono/stereo, high performance custom mixer, decent performance custom pitch shifter (does not stretch time) 1.08 C/C++ zlib
tinynet * Netcode for multiplayer games, reliable/unreliable packets, send/recieve large chunks reliably, encryption, network simulator, flow control, serialization + data integrity checks, compression 0.0 C/C++ zlib
tinytime Quick and dirty “main loop” timer function, along with utilities for integer-based high resolution timing 1.0 C/C++ zlib
tinymemfile Utility for calling fscanf-alike functions on files embedded in memory 1.0 C++ zlib
tinyfiles Directory traversal, both recursive and manual 1.0 C/C++ public domain
tinysid Compile time string hashing via preprocessing; turns strings into integers 1.0 C/C++ zlib
tinymath Professional level 3D vector math via SIMD intrinsics 1.1 C++ zlib
tinypng load/save PNG, texture atlas compiler, DEFLATE compliant decompressor 1.03 C/C++ public domain
tinygl OpenGL ES 3.0+ wrapper with carefully designed API to foster fast iteration 1.02 C/C++ zlib
tinyutf utf-8 and utf-16 encoder/decoder 1.0 C/C++ public domain
tinyhuff minimal static huffman encoder/decoder (compression) 1.0 C/C++ zlib
tinyspheremesh Generates beautiful vertices (triangles) of a sphere 1.0 C/C++ zlib
tinypath c-string utility functions for Shlwapi.h style path manipulation 1.01 C/C++ public domain
tinyalloc straight-forward but useful allocator collection 1.01 C/C++ public domain
tinymath2d 2d vector math and shape routines 1.0 C++ public domain
tinyspritebatch run-time 2d sprite batcher 0.01 C/C++ public domain


See miniz.c / miniz.h amalgamation on the (Releases)[]) page.


arious single-file C/C++ libraries.
All public domain.

library description
rjm_mc.h Uses Marching Cubes to convert an isosurface into triangles
rjm_raytrace.h Fast SSE packet raytracer, designed for AO baking.
rjm_texbleed.h Fills in the color of pixels where alpha==0


gb single-file public domain libraries for C & C++

library latest version category description
gb.h 0.27 misc Helper library (Standard library improvement)
gb_math.h 0.07e math Vector math library geared towards game development
gb_gl.h 0.05 graphics OpenGL Helper Library
gb_string.h 0.95a strings A better string library (this is built into gb.h too with custom allocator support!)
gb_ini.h 0.93 misc Simple ini file loader library
gb_regex.h 0.01d regex Highly experimental regular expressions library



Library Description
dr_flac FLAC audio decoder.
dr_wav WAV audio loader and writer.
dr_pcx PCX image loader.
dr_obj Wavefront OBJ model loader.
dr_fs File system abstraction for loading files from the native file system and archives.
dr_fsw Watch for changes to the file system. Windows only.
dr_math Vector math library. Very incomplete, and only updated as I need it.
dr Miscellaneous stuff that doesn’t belong to any specific category.


library lastest version category LoC license description
lexer.h 1.00 parser 1155 zlib simple lexer for C-like languages
json.h 1.00 parser 848 zlib non-allocating json parser
sched.h 1.00 multithreading 699 zlib multithreaded task scheduler
vec.h 0.02 math 2240 zlib vector math
web.h 1.00 network 1455 BSD lightweight webserver


Single file libraries for C/C++.

library category LoC license description
alsa.h audio 138 public domain ALSA [ref:]
wav.h audio 61 public domain Wave format [ref:]
v4l2.h video 614 public domain video for linux
clock.h utils 31 public domain clock function for linux [ref:]
kbhit.h utils 64 public domain kbhit function for linux [ref:]
ls.h utils 155 public domain making list of files and directories [ref:]
random.h math 32 public domain XOR128 random function
gpgpu_glsl.h GPGPU 383 public domain GLSL frameworks [ref:]
ocl.h GPGPU 190 public domain OpenCL frameworks
jo_mpeg.h video 317 public domain MPEG1/2 encoder []
minimp3.h audio 2671 LGPL MP3 decoder []
parg.h utils 551 CC0 Parser for argv that works similarly to getopt []
parson.h utils 2239 MIT Lightweight JSON library []

Written with StackEdit.