On this page
Overview
{fmt} is a C++ formatting library built around APIs such as fmt::format and fmt::print. Its API family influenced C++20 std::format and C++23 std::print, and it extends to dates, ranges, styled output, and user-defined types.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Build strings and output through type-safe fmt::format and fmt::print
Python-like format-string syntax supports positional arguments and format specifiers while keeping formatting tied to C++ types. With C++20, invalid format specifiers can be diagnosed at compile time.
Sources: [1]
Format dates, ranges, styled text, and user-defined types
Headers such as fmt/chrono.h, fmt/ranges.h, and fmt/color.h extend the same formatting model to dates, containers, and text styles, while custom formatters integrate user-defined types.
Sources: [1]
Best fit
Fits C++ codebases replacing printf or iostreams with consistent cross-platform formatting
It is useful when type safety, portable Unicode handling, formatting extensibility, and compile-time checking should be shared across applications and libraries.
Sources: [1]
Before adoption
Treat upstream benchmark numbers as workload-specific
The upstream README publishes performance comparisons against printf and iostreams, but results depend on compiler, optimization settings, and data patterns. Performance-driven adoption should be measured against the real application workload.
Sources: [1]
Review deprecated APIs and include changes in 12.2.0
Version 12.2.0 removes fmt::say, deprecates some fmt::join and related overloads, and changes <fmt/core.h> so it no longer implicitly provides all of <fmt/format.h> unless compatibility is requested.
Sources: [2]
Official sources
- [1]{fmt} 12.2.0 README(2026-10-04)
- [2]{fmt} 12.2.0 release(2026-10-04)
- [3]{fmt} 12.2.0 CMake configuration(2026-10-04)
- [4]{fmt} MIT license(2026-10-04)
Supplemental curator note
{fmt} is more than a printf replacement when a codebase needs type-safe format strings and consistent output rules across platforms. Evaluate real workload performance together with compile time and binary-size tradeoffs rather than relying only on published benchmarks.
Try it in 3 steps
- 1
Fetch the {fmt} 12.2.0 source
Pin the checkout to the reviewed latest release tag.
git clone --depth 1 --branch 12.2.0 https://github.com/fmtlib/fmt.git fmt-12.2.0 - 2
Build the library with CMake
Build the compiled library with documentation and tests disabled. The CMake configuration requests the C++11 compile feature.
cmake -S fmt-12.2.0 -B fmt-12.2.0/build -DFMT_TEST=OFF -DFMT_DOC=OFF && cmake --build fmt-12.2.0/build --config Release - 3
Compile and run a minimal
fmt::printprogramThis is a Unix-like toolchain example.
answer=42confirms basic formatting and linking. On Windows, link the generated CMake target from Visual Studio instead.cd fmt-12.2.0 && printf '#include <fmt/base.h>\nint main() { fmt::print("answer={}\\n", 42); }\n' > demo.cc && c++ -std=c++11 demo.cc -Iinclude build/libfmt.a -o demo && ./demo
Growth
Growth trends · Last 30 days
25,864 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 60
- Open PRs
- 6
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- formatting
- printf
- output
- chrono
- performance
- multiplatform
- cross-platform
- cpp
- ranges
- floating-point
- unicode
- c-plus-plus
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- React Native126,790 Stars
2 shared tag(s) · 1 shared category(s) · Same language
native mobile UI with React, stable 0.87.1, and a framework-first path
C++ - Electron123,376 Stars
2 shared tag(s) · 1 shared category(s) · Same language
bundle Chromium and Node.js to build desktop applications for three major operating systems with HTML, CSS, and JavaScript
C++ - Folly30,551 Stars
2 shared tag(s) · 1 shared category(s) · Same language
use a practical, performance-focused collection of C++20 core components developed for large-scale Meta systems
C++ - Godot Engine118,086 Stars
2 shared tag(s) · Same language
Build 2D and 3D games in one editor and export them to desktop, mobile, and the web
C++ - OpenCV91,053 Stars
2 shared tag(s) · Same language
a computer-vision foundation with major toolchain and API changes in 5.0
C++ - gRPC45,361 Stars
2 shared tag(s) · Same language
define service contracts with Protocol Buffers and implement high-performance RPC over HTTP/2 across languages
C++
Report incorrect information
Tell us if any listing information is incorrect or outdated.