A lightweight pure-Swift library for downloading, caching and displaying images from the web in iOS, macOS and SwiftUI apps.
nothings/stb
A collection of single-file, public domain (or MIT) C/C++ libraries for image loading, font rasterizing, data structures and more.
- Stars
- 34,891
- Forks
- 8,111
- Open issues
- 438
- Last commit
- 2 days ago
What is it?
stb is a set of independent C/C++ libraries, each distributed as a single header file that you can drop into a project without a build system or package manager. Most files act as headers by default, and you enable the implementation by defining a per-library macro in exactly one source file.
The collection covers a broad range of tasks. Notable libraries include stb_image for decoding JPG, PNG, TGA, BMP, PSD, GIF, HDR and PIC images, stb_image_write for writing PNG, TGA and BMP files, stb_truetype for parsing and rasterizing TrueType fonts, and stb_ds for typesafe dynamic arrays and hash tables in C. Others handle Ogg Vorbis decoding, rectangle packing, Perlin noise, text editing logic, voxel rendering and tilemap editing.
Each library is public domain, and can also be used under MIT. The author notes that these libraries are generally easier to integrate than larger alternatives, though they may be less feature-complete or slower.
Key features
- 01Each library ships as a single file with no external dependencies.
- 02stb_image decodes many common image formats from file or memory.
- 03stb_truetype parses and rasterizes TrueType fonts.
- 04stb_ds provides typesafe dynamic arrays and hash tables for C.
- 05Libraries are public domain or MIT licensed, so they can be reused freely.
Use cases
- Loading textures or images in a C or C++ game or tool without linking a large library.
- Rendering text from TrueType fonts in a custom graphics engine.
- Adding dynamic arrays or hash maps to a C project with no extra dependencies.
- Vendoring small utilities into a project that must avoid complex build setups.
Quick start
- 1
Download the single-file header you need (e.g. stb_image.h) from the repository
- 2
In exactly one C/C++ source file, define the implementation macro and include the header
Things to know
- The stb_image.h maintainer will not add new image formats, so format support is fixed.
- Security-relevant bugs are discussed publicly and fixes may take significant time.
- The license is listed as NOASSERTION in metadata, though the README states public domain or MIT dual license.
Topics
FAQ
- What is stb?
- A collection of single-file, public domain (or MIT) C/C++ libraries for image loading, font rasterizing, data structures and more. stb is a set of independent C/C++ libraries, each distributed as a single header file that you can drop into a project without a build system or package manager. Most files act as headers by default, and you enable the implementation by defining a per-library macro in exactly one source file.
- Is stb free to use? What license does it have?
- stb is open source under the Other license. Check the license terms before using it in commercial products.
- Is stb still maintained?
- Actively maintained. The last commit to stb was on Oct 23, 2026.
- What can I use stb for?
- Loading textures or images in a C or C++ game or tool without linking a large library. Rendering text from TrueType fonts in a custom graphics engine. Adding dynamic arrays or hash maps to a C project with no extra dependencies. Vendoring small utilities into a project that must avoid complex build setups.
- How do I install stb?
- Download the single-file header you need (e.g. stb_image.h) from the repository In exactly one C/C++ source file, define the implementation macro and include the header
- Where can I get stb?
- The source code and installation instructions are on GitHub: https://github.com/nothings/stb
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Swift image loading system for Apple platforms with caching, processing, progressive decoding, and SwiftUI/UIKit components.
A pure-Python utility library of 230+ extra constructs that extend the standard library, with no dependencies.
A Chinese-language LeetCode study guide with a curated problem order, illustrated solutions, video explanations, and code in C++, Java, Python, Go and JavaScript.
A educational collection of algorithms and data structures implemented in C++17 with no external libraries, spanning math, ML, CS and physics.
A community-maintained collection of algorithms implemented in Python, intended for learning and education.