Your company here — click to reach over 10,000 unique daily visitors

flatc - Man Page

flatc – FlatBuffers compiler


flatc [OPTION]... FILE... [-- BINARY_FILE...]


FILEs may be schemas (must end in .fbs), binary schemas (must end in .bfbs), or JSON files (conforming to preceding schema). BINARY_FILEs after the -- must be binary flatbuffer format files.

Output files are named using the base file name of the input, and written to the current directory or the path given by -o.

--binary,  -b

Generate wire format binaries for any data definitions.

--json,  -t

Generate text output for any data definitions.

--cpp,  -c

Generate C++ headers for tables/structs.

--go,  -g

Generate Go files for tables/structs.

--java,  -j

Generate Java classes for tables/structs.

--dart,  -d

Generate Dart classes for tables/structs.

--ts,  -T

Generate TypeScript code for tables/structs.

--csharp,  -n

Generate C# classes for tables/structs.

--python,  -p

Generate Python files for tables/structs.


Generate Lobster files for tables/structs.

--lua,  -l

Generate Lua files for tables/structs.

--rust,  -r

Generate Rust files for tables/structs.


Generate PHP files for tables/structs.


Generate Kotlin classes for tables/structs.


Generate Json schema.


Generate Swift files for tables/structs.


Generate Nim files for tables/structs.


Prefix PATH to all generated files.


Search for includes in the specified path.


Print make(1) rules for generated files.


Print the version number of flatc and exit.


Strict JSON: field names must be / will be quoted, no trailing commas in tables/vectors.


Pass non-UTF-8 input through parser and emit nonstandard \x escapes in JSON. (Default is to raise parse error on non-UTF-8 input.)


Output strings with UTF-8 as human-readable strings. By default, UTF-8 characters are printed as \uXXXX escapes.


Output fields whose value is the default when writing JSON.


Allow fields in JSON that are not defined in the schema. These fields will be discared when generating binaries.


Don’t prefix enum values with the enum type in C++.


Use C++11 style scoped and strongly typed enums. Also implies --no-prefix.


Disable generation of MIN and MAX enumerated values for scoped enums and prefixed enums.


(deprecated), this is the default behavior. If the original behavior is required (no include statements) use --no-includes.


Don’t generate include statements for included schemas the generated file depends on (C++ / Python).


Generate accessors that can mutate buffers in-place.


Generate single output file for C# and Go.


Generate type name functions for C++ and Rust.


Generate an additional object-based API.


Generate operator== for object-based API types.


Add Clang _Nullable for C++ pointer. or @Nullable for Java


Add a prefix to the generated package name for Java.


Add @Pure for Java.


Add @Generated annotation for Java


Add @JvmStatic annotation for Kotlin methods in companion object for interop from Java to Kotlin.


Generate not just code for the current schema files, but for all files it includes as well. If the language uses a single file for output (by default the case for C++ and JS), all code will end up in this one file.


Generates encoding code which emits Flatbuffers into JSON.


Adds an #include in generated file.

--cpp-ptr-type T

Set object API pointer type (default std::unique_ptr).

--cpp-str-type T

Set object API string type (default std::string). T::c_str(), T::length(), and T::empty() must be supported. The custom type also needs to be constructible from std::string (see the --cpp-str-flex-ctor option to change this behavior).


Don’t construct custom string types by passing std::string from Flatbuffers, but (char* + length).

--cpp-std CPP_STD

Generate a C++ code using features of selected C++ standard.

Supported CPP_STD values:

  • c++0x – generate code compatible with old compilers;
  • c++11 – use C++11 code generator (default);
  • c++17 – use C++17 features in generated code (experimental).

When using C++17, generate extra code to provide compile-time (static) reflection of Flatbuffers types. Requires --cpp-std to be “c++17” or higher.


Customise class prefix for C++ object-based API.


Customise class suffix for C++ object-based API. Default value is “T”.


Generate the overriding namespace in Golang.


Generate the overriding import for flatbuffers in Golang (default is “github.com/google/flatbuffers/go”).


Prefix local import paths of generated go code with the module name.


Allow binaries without file_identifier to be read. This may crash flatc given a mismatched schema.


Input binaries are size prefixed buffers.

--proto-namespace-suffix SUFFIX

Add this namespace to any flatbuffers generated from protobufs.


Translate .proto oneofs to flatbuffer unions.


Keep protobuf field ids in generated fbs file.


Action that should be taken when a gap between protobuf ids found.

Supported values:

  • nop – do not care about gap
  • warn – A warning message will be shown about the gap in protobuf ids (default)
  • error – An error message will be shown and the fbs generation will be interrupted.

Generate GRPC interfaces for the specified languages.


Serialize schemas instead of JSON (use with -b).


Add doc comments to the binary schema files.


Add builtin attributes to the binary schema files.


Generate code to embed the bfbs schema to the source.

--conform FILE

Specify a schema the following schemas should be an evolution of. Gives errors if not.


Include path for the schema given with --conform PATH.


The suffix appended to the generated file names. Default is _generated’.


The extension appended to the generated file names. Default is language-specific (e.g., ‘.h’ for C++)

--include-prefix PATH

Prefix this path to any generated include statements.


Keep original prefix of schema include statement.


Add minimal type reflection to code generation.


Add minimal type/name reflection.


Implement serde::Serialize on generated Rust types.


Generate rust code in individual files with a module root file.

--root-type T

Select or override the default root_type.


When parsing schemas, require explicit ids (id: x).


Emit default values in binary output from JSON.


When serializing from object API representation, force strings and vectors to empty rather than null.


When serializing from object API representation, force vectors to empty rather than null.


Used with “binary” and “json” options, it generates data using schema-less FlexBuffers.


Inhibit all warning messages.


Treat all warnings as errors.


Prepend “global::” to all user generated csharp classes and structs.


Allows (de)serialization of JSON text in the Object API. (requires --gen-object-api).


Allow a nested_flatbuffer field to be parsed as a vector of bytes in JSON, which is unsafe unless checked by a verifier afterwards.


Generate a single typescript file per .fbs file. Implies --ts-entry-points.


Generate entry point typescript per namespace. Implies --gen-all.

--annotate-sparse-vectors SCHEMA

Don’t annotate every vector element.

--annotate SCHEMA

Annotate the provided BINARY_FILE with the specified SCHEMA file.


Prevents multiple type of annotations within a Fbs SCHEMA file. Currently this is required to generate private types in Rust.


Skip emission of Python functions that are prefixed with typenames


Generate Python type annotations


Print out generated file names without writing to the files


flatc -c -b schema1.fbs schema2.fbs data.json

See Also

Official documentation


October 2022