fmt: Format C++ Text Safely and Efficiently

fmt: Format C++ Text Safely and Efficiently

Summary

{fmt} is a C++ formatting library for producing text and output without relying on C stdio or iostreams. It suits projects that need a type-safe, portable formatting API, with optional compile-time format checks and a header-only mode.

At a glance

Language
C++
License
MIT
Stars
25.9k
Forks
3.1k
Added to OSRepos
November 18, 2025
Last analyzed
October 3, 2026
View on GitHub

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Overview

{fmt} is a C++ library for formatting values into strings and writing formatted output. It offers an alternative to C stdio and iostreams, with a Python-like format syntax and type-safe argument handling.

It is useful when an application needs consistent formatting across platforms, support for custom types, or control over formatting performance and compile-time checks. The project also implements C++20 std::format and C++23 std::print interfaces.

Key Features

  • Format strings and print output using positional or automatic arguments.
  • Support for compile-time format-string checks in C++20.
  • Format numbers, dates, times, ranges, Unicode text, colors, and user-defined types.
  • Provide a safe printf-style API, including positional arguments.
  • Offer an optional header-only configuration with FMT_HEADER_ONLY.
  • Include tests and continuous fuzzing, according to the project README.

Use Cases

  • C++ application developers can use it to format strings and console output with type-checked arguments.
  • Library authors can add formatting support for custom types through the extension API.
  • Teams targeting multiple platforms can use it for consistent formatting behavior and Unicode support.
  • Performance-sensitive applications can evaluate it as an alternative to iostreams or stdio for formatting workloads.
  • Projects that want to adopt familiar standard formatting interfaces can use its std::format and std::print implementations.

Project Facts

  • Language: C++
  • License: MIT
  • Stars: 25.9k
  • Forks: 3.1k
  • Topics: c-plus-plus, chrono, cpp, cross-platform, floating-point, formatting, multiplatform, output, performance, printf, ranges, unicode
  • Archived: No

Getting Started

See the README and documentation for installation and build instructions. A basic example is:

#include <fmt/core.h>

int main() {
  fmt::print("Hello, world!\n");
}

Considerations

  • This is a C++ library, so using it requires a C++ project and a compatible compiler. The README describes support for older compilers but does not list requirements here.
  • Header-only use is optional. Projects can instead build and link the library.
  • Performance depends on the workload and environment. Consult the linked benchmarks and methodology before choosing it on performance grounds.

Found this useful?

Share it with someone who would like fmt.

Source repository

Open the original repository on GitHub.

22 counted GitHub visits

View on GitHub

Related repositories

Similar repositories that may be relevant next.

OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️