explaingit

nothings/stb

33,676CAudience · developerComplexity · 2/5MaintainedLicenseSetup · easy

TLDR

Single-header C/C++ utility libraries for images, fonts, audio, and game dev, copy one file, no dependencies, no build changes.

Mindmap

mindmap
  root((stb))
    What it does
      Image loading
      Font rendering
      Audio decoding
      Utility functions
    Key libraries
      stb_image.h
      stb_truetype.h
      stb_image_write.h
      stb_image_resize2.h
    Design approach
      Single header files
      No external deps
      Public domain/MIT
    Use cases
      Game development
      Graphics programs
      Embedded systems
      Minimal projects

Things people build with this

USE CASE 1

Load and save images (JPEG, PNG, BMP, GIF, TGA) in a game or graphics app without external libraries.

USE CASE 2

Render TrueType fonts as pixels for text display in embedded or game projects.

USE CASE 3

Decode Ogg Vorbis audio files for sound effects and music in games.

USE CASE 4

Generate Perlin noise for procedural terrain or texture generation.

Tech stack

CC++

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial, with no restrictions, public domain or MIT licensed.

In plain English

stb is a collection of small, self-contained utility libraries for C and C++ programming, each distributed as a single header file. The central idea is that adding a library to a project should be as simple as copying one file, no build system changes, no external dependencies, no linking complications. Each library is either public domain or MIT licensed, meaning you can use it in any project with essentially no legal restrictions. The collection covers 21 libraries spanning graphics, audio, game development, and general utilities. The most widely used are stb_image.h (loading image files in formats like JPEG, PNG, BMP, GIF, and TGA), stb_image_write.h (saving images to disk), stb_image_resize2.h (scaling images up or down with good quality), and stb_truetype.h (parsing TrueType font files and rendering text as pixels). There are also libraries for Ogg Vorbis audio decoding, Perlin noise generation, dynamic arrays and hash tables in C, fast string formatting, voxel rendering, and more. The single-header design works by putting all the code in one .h file. By default including the file only declares the API (the function signatures); you enable the actual implementation by defining a specific macro in exactly one source file before including it. Someone would use stb when writing a C or C++ program that needs image loading, font rendering, or similar functionality without adding a large dependency. It is especially popular in game development, graphics programming, and embedded systems where keeping dependencies minimal is important. The README includes a note that security bugs are discussed publicly and fixes may take time, which is relevant for security-sensitive applications.

Copy-paste prompts

Prompt 1
Show me how to use stb_image.h to load a PNG file and access its pixel data in my C program.
Prompt 2
How do I render text using stb_truetype.h? Walk me through parsing a font file and drawing glyphs.
Prompt 3
I need to resize an image in C without external dependencies, how do I use stb_image_resize2.h?
Prompt 4
What's the single-header pattern in stb libraries and how do I enable the implementation in my code?
Prompt 5
Compare stb_image.h to other image loading libraries, why would I choose stb for a minimal project?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.