flatbuffers README

The project's README from github.com/google/flatbuffers. As one markdown file: README.md.

logo FlatBuffers

Build status BuildKite status Fuzzing Status Discord Chat Twitter Follow Twitter Follow

FlatBuffers is a cross platform serialization library architected for maximum memory efficiency. It allows you to directly access serialized data without parsing/unpacking it first, while still having great forwards/backwards compatibility.

Quick Start

  1. Build the compiler for flatbuffers (flatc)

    Use cmake to create the build files for your platform and then perform the compilation (Linux example).

    cmake -G "Unix Makefiles"
    make -j
    
  2. Define your flatbuffer schema (.fbs)

    Write the schema to define the data you want to serialize. See monster.fbs for an example.

  3. Generate code for your language(s)

    Use the flatc compiler to take your schema and generate language-specific code:

    ./flatc --cpp --rust monster.fbs
    

    Which generates monster_generated.h and monster_generated.rs files.

  4. Serialize data

    Use the generated code, as well as the FlatBufferBuilder to construct your serialized buffer. (C++ example)

  5. Transmit/store/save Buffer

    Use your serialized buffer however you want. Send it to someone, save it for later, etc...

  6. Read the data

    Use the generated accessors to read the data from the serialized buffer.

    It doesn't need to be the same language/schema version, FlatBuffers ensures the data is readable across languages and schema versions. See the Rust example reading the data written by C++.

Documentation

Go to our landing page to browse our documentation.

Supported operating systems

Supported programming languages

Code generation and runtime libraries for many popular languages.

  1. C
  2. C++ - snapcraft.io
  3. C# - nuget.org
  4. Dart - pub.dev
  5. Go - go.dev
  6. Java - Maven
  7. JavaScript - NPM
  8. Kotlin
  9. Lobster
  10. Lua
  11. PHP
  12. Python - PyPI
  13. Rust - crates.io
  14. Swift - swiftpackageindex
  15. TypeScript - NPM
  16. Nim

Versioning

FlatBuffers does not follow traditional SemVer versioning (see rationale) but rather uses a format of the date of the release.

Contribution

To contribute to this project, see CONTRIBUTING.

Community

Security

Please see our Security Policy for reporting vulnerabilities.

Licensing

Flatbuffers is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.


flatbuffers (google/flatbuffers)

Searching Database…

What is this?FlatBuffers is a cross-platform serialization library built for maximum memory efficiency: you read serialized data directly without a parsing/unpacking step, and it keeps forwards/backwards compatibility.
So is it a library I link into my code, or a separate tool?Both halves: runtime libraries you link into your app, plus the flatc compiler that takes your schema and generates language-specific accessors and builder code from a .fbs file.
What's the workflow to get my data into a FlatBuffer?Build flatc with cmake, define your schema in a .fbs file, run flatc to generate code for your language, serialize with FlatBufferBuilder, then read the buffer back with the generated accessors.
Which languages can I use it from?Code generation and runtimes for C, C++, C#, Dart, Go, Java, JavaScript, Kotlin, Lobster, Lua, PHP, Python, Rust, Swift, TypeScript and Nim, shipped via npm, PyPI, NuGet, Maven, crates.io, pub.dev and more.
Are there any gotchas around versioning when I add it as a dependency?Yes — releases are dated instead of following SemVer, so don't expect 1.2.3-style version numbers when pinning it in your package manager.
Does it work on Windows and macOS, or only Linux?All of them — Windows, macOS, Linux and Android are explicitly supported, plus any other OS with a recent C++ compiler (C++ 11 or newer).
Is it free to use, even commercially?Yes, it's licensed under Apache License 2.0, a permissive open-source license with no paid tier.
Can I read a buffer written by another language, or an older schema version?Yes. The reader doesn't need the same language or schema version — FlatBuffers keeps data readable across languages and schema versions; the README shows Rust reading a buffer that C++ wrote.
Why pick it over a format I have to parse, like JSON?The core pitch: you access serialized data directly without parsing or unpacking it first, which is where the memory efficiency comes from, and cross-version compatibility is built in.
Creator
google
Size
21.7 MB
Stars
26.6K
Age
12y
Commits · 90 Days