ConfigsMay 5, 2026·3 min read

Flecs — Fast Entity Component System for C and C++

A high-performance ECS framework for C99 and C++11 with a built-in query language, REST API explorer, and support for multithreading and hierarchical scenes.

Introduction

Flecs is an entity-component-system framework for C and C++ that combines high iteration performance with a rich feature set including relationships, queries, reactive systems, and a web-based explorer. It is used in games, simulations, and data-oriented applications.

What Flecs Does

  • Manages entities and components with cache-friendly archetype storage
  • Provides a powerful query language supporting filters, rules, and change detection
  • Supports entity relationships and hierarchies for scene graphs and prefabs
  • Includes multithreaded task scheduling for parallel system execution
  • Offers a REST API and web explorer for live inspection of the ECS world

Architecture Overview

Flecs uses archetype-based storage where entities sharing the same component set are stored together in tables. This layout maximizes cache utilization during iteration. Queries compile into optimized iteration plans at creation time. The framework also supports a unique relationship model that allows expressing parent-child hierarchies, tags, and component pairs directly in the ECS.

Self-Hosting & Configuration

  • Single-file distribution: add flecs.h and flecs.c to your project
  • Also available via CMake, vcpkg, Conan, and other C/C++ package managers
  • Works with C99 and C++11 compilers on all major platforms
  • Configure threading, time step, and pipeline stages via the world API
  • Enable the REST module for the web-based entity explorer on localhost

Key Features

  • Archetype storage delivers high iteration throughput with minimal overhead
  • First-class relationships express hierarchies, groups, and tagged connections
  • Built-in web explorer lets you browse entities, components, and systems in a browser
  • Prefab system allows defining reusable entity templates with inheritance
  • Change detection triggers systems only when relevant data is modified

Comparison with Similar Tools

  • EnTT — Header-only C++17 with sparse sets; Flecs uses archetypes and offers a C API
  • Bevy ECS — Rust-native; Flecs targets C/C++ and has a richer query language
  • Unity DOTS — Proprietary and C#; Flecs is open source and language-agnostic
  • ENTT — Compile-time typed; Flecs adds runtime queries and a web explorer
  • Specs — Rust ECS (archived); Flecs is actively maintained with frequent releases

FAQ

Q: Should I use the C or C++ API? A: Both wrap the same core. The C++ API adds type safety and convenience, while the C API is more portable and can be called from other languages via FFI.

Q: How does Flecs handle multithreading? A: Flecs includes a built-in pipeline scheduler that distributes systems across worker threads. Systems declare their read/write dependencies, and the scheduler ensures safe parallel execution.

Q: What is the Flecs Explorer? A: A browser-based UI served by the engine's REST module that lets you inspect entities, query components, and monitor system performance in real time.

Q: Can Flecs be used outside of games? A: Yes. Its data-oriented architecture works well for simulations, IoT data processing, and any application managing large numbers of entities with heterogeneous data.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets