nothings/stb logo

nothings/stb

Free

stb single-file public domain libraries for C/C++

FreeFree tier
Type
Open Source

About nothings/stb

stb is a collection of single-file public domain (or MIT licensed) libraries for C/C++ developed primarily by Sean Barrett (nothings). The project provides over 20 header-only libraries covering a wide range of functionality including image loading (stb_image.h), image writing (stb_image_write.h), image resizing (stb_image_resize2.h), TrueType font rasterization (stb_truetype.h), Ogg Vorbis audio decoding (stb_vorbis.c), audio waveform synthesis (stb_hexwave.h), typesafe dynamic arrays and hash tables (stb_ds.h), fast sprintf/snprintf (stb_sprintf.h), text editor guts (stb_textedit.h), voxel rendering (stb_voxel_render.h), rectangle packing (stb_rect_pack.h), Perlin noise (stb_perlin.h), DXT compression (stb_dxt.h), tilemap editing (stb_tilemap_editor.h), and more. Each library is designed to be easy to integrate by simply copying the single file into your project. The libraries are widely used in game development, graphics applications, and other C/C++ projects. The repository has over 34,000 stars on GitHub.

Key Features

Single-file header/source libraries, no build system required
Public domain or MIT licensed for maximum permissiveness
Over 20 libraries covering graphics, audio, utility, game development, and parsing
Includes popular libraries: stb_image.h (image loading), stb_truetype.h (font rasterization), stb_vorbis.c (audio decoding), stb_ds.h (dynamic arrays/hash tables)
Widely used in game and graphics development
Well-documented with version history and LoC counts

Pros & Cons

Pros
  • Extremely easy to integrate: just copy the single file into your project
  • Permissive licensing (public domain or MIT) allows use in any project
  • Covers a broad range of functionality, reducing external dependencies
  • Mature and battle-tested with many years of development
  • Large community (34.3k stars, 8.1k forks) and active issue tracking
Cons
  • Security fixes may take significant time to be implemented or merged (as stated in the repository)
  • Some libraries may have incomplete or outdated documentation
  • Not all libraries are equally maintained; some are older or experimental

Best For

Loading images (JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC) from file or memoryWriting images to disk (PNG, TGA, BMP)Rasterizing TrueType fonts for text renderingDecoding Ogg Vorbis audio files to float or 16-bit signed outputImplementing dynamic arrays and hash tables in CResizing images with good qualityBuilding texture atlas tools with rectangle packingGenerating Perlin noise for procedural content

FAQ

What is stb?
stb is a collection of single-file public domain (or MIT licensed) libraries for C/C++ created by Sean Barrett (nothings). It includes libraries for image loading, font rendering, audio decoding, data structures, and more.
Is stb free to use?
Yes. Most libraries are public domain, and some are MIT licensed. They are free to use in any project, including commercial projects.
How do I use an stb library?
Simply copy the single header file (e.g., stb_image.h) into your project and include it. Some libraries require defining a specific macro before inclusion to implement the source code, as detailed in the documentation.
What libraries are included?
The repository includes over 20 libraries: stb_image.h, stb_image_write.h, stb_image_resize2.h, stb_truetype.h, stb_vorbis.c, stb_hexwave.h, stb_ds.h, stb_sprintf.h, stb_textedit.h, stb_voxel_render.h, stb_rect_pack.h, stb_perlin.h, stb_dxt.h, stb_easy_font.h, stb_tilemap_editor.h, stb_herringbone_wang_tile.h, stb_c_lexer.h, stb_divide.h, stb_connected_components.h, stb_leakcheck.h, and more.