OS Manuals

/usr/bin/flatc

The FlatBuffers serialization format

From flatbuffers 25.12.19-r7 (os), captured 2026-11-05 by running flatc --help (exit 0). permalink

Usage: /usr/bin/flatc [OPTION]... FILE... [-- BINARY_FILE...]
  -b, --binary           Generate wire format binaries for any data definitions
  -c, --cpp              Generate C++ headers for tables/structs
  -n, --csharp           Generate C# classes for tables/structs
  -d, --dart             Generate Dart classes for tables/structs
  -g, --go               Generate Go files for tables/structs
  -j, --java             Generate Java classes for tables/structs
  -t, --json             Generate text output for any data definitions
  --jsonschema           Generate Json schema
  --kotlin               Generate Kotlin classes for tables/structs
  --kotlin-kmp           Generate Kotlin multiplatform classes for
                         tables/structs
  --lobster              Generate Lobster files for tables/structs
  -l, --lua              Generate Lua files for tables/structs
  --nim                  Generate Nim files for tables/structs
  --php                  Generate PHP files for tables/structs
  --proto                Input is a .proto, translate to .fbs
  -p, --python           Generate Python files for tables/structs
  -r, --rust             Generate Rust files for tables/structs
  --swift                Generate Swift files for tables/structs
  -T, --ts               Generate TypeScript code for tables/structs

  -o PATH                Prefix PATH to all generated files.
  -I PATH                Search for includes in the specified path.
  -M                     Print make rules for generated files.
  --version              Print the version number of flatc and exit.
  -h, --help             Prints this help text and exit.
  --strict-json          Strict JSON: field names must be / will be quoted, no
                         trailing commas in tables/vectors.
  --allow-non-utf8       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.)
  --natural-utf8         Output strings with UTF-8 as human-readable strings. By
                         default, UTF-8 characters are printed as \uXXXX
                         escapes.
  --defaults-json        Output fields whose value is the default when writing
                         JSON
  --unknown-json         Allow fields in JSON that are not defined in the
                         schema. These fields will be discarded when generating
                         binaries.
  --no-prefix            Don't prefix enum values with the enum type in C++.
  --scoped-enums         Use C++11 style scoped and strongly typed enums. Also
                         implies --no-prefix.
  --no-emit-min-max-enum-values
                         Disable generation of MIN and MAX enumerated values for
                         scoped enums and prefixed enums.
  --swift-implementation-only
                         Adds a @_implementationOnly to swift imports
  --gen-includes         (deprecated), this is the default behavior. If the
                         original behavior is required (no include statements)
                         use --no-includes.
  --no-includes          Don't generate include statements for included schemas
                         the generated file depends on (C++, Python,
                         Proto-to-Fbs).
  --gen-mutable          Generate accessors that can mutate buffers in-place.
  --gen-onefile          Generate a single output file for C#, Go, Java, Kotlin
                         and Python. Implies --no-include.
  --gen-name-strings     Generate type name functions for C++ and Rust.
  --gen-object-api       Generate an additional object-based API.
  --gen-compare          Generate operator== for object-based API types.
  --gen-nullable         Add Clang _Nullable for C++ pointer. or @Nullable for
                         Java
  --java-package-prefix  Add a prefix to the generated package name for Java.
  --java-checkerframework
                         Add @Pure for Java.
  --gen-generated        Add @Generated annotation for Java.
  --gen-jvmstatic        Add @JvmStatic annotation for Kotlin methods in
                         companion object for interop from Java to Kotlin.
  --gen-all              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.
  --gen-json-emit        Generates encoding code which emits Flatbuffers into
                         JSON
  --cpp-include          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)
  --cpp-str-flex-ctor    Don't construct custom string types by passing
                         std::string from Flatbuffers, but (char* + length).
  --cpp-field-case-style STYLE
                         Generate C++ fields using selected case style.
                         Supported STYLE values: * 'unchanged' - leave unchanged
                         (default) * 'upper' - schema snake_case emits
                         UpperCamel; * 'lower' - schema snake_case emits
                         lowerCamel.
  --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).
  --cpp-static-reflection
                         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.
  --object-prefix PREFIX Customize class prefix for C++ object-based API.
  --object-suffix SUFFIX Customize class suffix for C++ object-based API.
                         Default Value is "T".
  --go-namespace         Generate the overriding namespace in Golang.
  --go-import IMPORT     Generate the overriding import for flatbuffers in
                         Golang (default is "github.com/google/flatbuffers/go").
  --go-module-name       Prefix local import paths of generated go code with the
                         module name
  --raw-binary           Allow binaries without file_identifier to be read. This
                         may crash flatc given a mismatched schema.
  --size-prefixed        Input binaries are size prefixed buffers.
  --proto-namespace-suffix SUFFIX
                         Add this namespace to any flatbuffers generated from
                         protobufs.
  --oneof-union          Translate .proto oneofs to flatbuffer unions.
  --keep-proto-id        Keep protobuf field ids in generated fbs file.
  --proto-id-gap         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.
  --grpc                 Generate GRPC interfaces for the specified languages.
  --schema               Serialize schemas instead of JSON (use with -b).
  --bfbs-filenames PATH  Sets the root path where reflection filenames in
                         reflection.fbs are relative to. The 'root' is denoted
                         with  `//`. E.g. if PATH=/a/b/c then /a/d/e.fbs will be
                         serialized as //../d/e.fbs. (PATH defaults to the
                         directory of the first provided schema file.
  --bfbs-absolute-paths  Uses absolute paths instead of relative paths in the
                         BFBS output.
  --bfbs-comments        Add doc comments to the binary schema files.
  --bfbs-builtins        Add builtin attributes to the binary schema files.
  --bfbs-gen-embed       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.
  --conform-includes PATH
                         Include path for the schema given with --conform PATH
  --filename-suffix SUFFIX
                         The suffix appended to the generated file names
                         (Default is '_generated').
  --filename-ext EXT     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-prefix          Keep original prefix of schema include statement.
  --reflect-types        Add minimal type reflection to code generation.
  --reflect-names        Add minimal type/name reflection.
  --rust-serialize       Implement serde::Serialize on generated Rust types.
  --rust-module-root-file
                         Generate rust code in individual files with a module
                         root file.
  --root-type T          Select or override the default root_type.
  --require-explicit-ids When parsing schemas, require explicit ids (id: x).
  --force-defaults       Emit default values in binary output from JSON
  --force-empty          When serializing from object API representation, force
                         strings and vectors to empty rather than null.
  --force-empty-vectors  When serializing from object API representation, force
                         vectors to empty rather than null.
  --flexbuffers          Used with "binary" and "json" options, it generates
                         data using schema-less FlexBuffers.
  --no-warnings          Inhibit all warnings messages.
  --warnings-as-errors   Treat all warnings as errors.
  --cs-global-alias      Prepend "global::" to all user generated csharp classes
                         and structs.
  --cs-gen-json-serializer
                         Allows (de)serialization of JSON text in the Object
                         API. (requires --gen-object-api).
  --json-nested-bytes    Allow a nested_flatbuffer field to be parsed as a
                         vector of bytes in JSON, which is unsafe unless checked
                         by a verifier afterwards.
  --ts-flat-files        (deprecated) Alias for --gen-all.
  --ts-entry-points      (deprecated) Alias for --gen-all.
  --annotate-sparse-vectors
                         Don't annotate every vector element.
  --annotate SCHEMA      Annotate the provided BINARY_FILE with the specified
                         SCHEMA file.
  --no-leak-private-annotation
                         Prevents multiple type of annotations within a Fbs
                         SCHEMA file. Currently this is required to generate
                         private types in Rust
  --python-no-type-prefix-suffix
                         Skip emission of Python functions that are prefixed
                         with typenames
  --python-typing        Generate Python type annotations
  --python-version       Generate code for the given Python version.
  --python-decode-obj-api-strings
                         Decode bytes to strings for the Python Object API
  --python-gen-numpy     Whether to generate numpy helpers.
  --ts-omit-entrypoint   Omit emission of namespace entrypoint file
  --file-names-only      Print out generated file names without writing to the
                         files
  --grpc-filename-suffix SUFFIX
                         The suffix for the generated file names (Default is
                         '.fb').
  --grpc-additional-header
                         Additional headers to prepend to the generated files.
  --grpc-use-system-headers
                         Use <> for headers included from the generated code.
  --grpc-search-path PATH
                         Prefix to any gRPC includes.
  --grpc-python-typed-handlers
                         The handlers will use the generated classes rather than
                         raw bytes.
  --grpc-callback-api    Generate gRPC code using the callback (reactor) API
                         instead of legacy sync/async.

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.
example: /usr/bin/flatc -c -b schema1.fbs schema2.fbs data.json
Options (108)
OptionDescriptionSource
-b, --binaryGenerate wire format binaries for any data definitionshelp
-c, --cppGenerate C++ headers for tables/structshelp
-n, --csharpGenerate C# classes for tables/structshelp
-d, --dartGenerate Dart classes for tables/structshelp
-g, --goGenerate Go files for tables/structshelp
-j, --javaGenerate Java classes for tables/structshelp
-t, --jsonGenerate text output for any data definitionshelp
--jsonschemaGenerate Json schemahelp
--kotlinGenerate Kotlin classes for tables/structshelp
--kotlin-kmpGenerate Kotlin multiplatform classes for tables/structshelp
--lobsterGenerate Lobster files for tables/structshelp
-l, --luaGenerate Lua files for tables/structshelp
--nimGenerate Nim files for tables/structshelp
--phpGenerate PHP files for tables/structshelp
--protoInput is a .proto, translate to .fbshelp
-p, --pythonGenerate Python files for tables/structshelp
-r, --rustGenerate Rust files for tables/structshelp
--swiftGenerate Swift files for tables/structshelp
-T, --tsGenerate TypeScript code for tables/structshelp
-o PATHPrefix PATH to all generated files.help
-I PATHSearch for includes in the specified path.help
-MPrint make rules for generated files.help
--versionPrint the version number of flatc and exit.help
-h, --helpPrints this help text and exit.help
--strict-jsonStrict JSON: field names must be / will be quoted, no trailing commas in tables/vectors.help
--allow-non-utf8Pass non-UTF-8 input through parser and emit nonstandard \x escapes in JSON.help
--natural-utf8Output strings with UTF-8 as human-readable strings.help
--defaults-jsonOutput fields whose value is the default when writing JSONhelp
--unknown-jsonAllow fields in JSON that are not defined in the schema.help
--no-prefixDon't prefix enum values with the enum type in C++.help
--scoped-enumsUse C++11 style scoped and strongly typed enums.help
--no-emit-min-max-enum-valuesDisable generation of MIN and MAX enumerated values for scoped enums and prefixed enums.help
--swift-implementation-onlyAdds a @_implementationOnly to swift importshelp
--gen-includes(deprecated), this is the default behavior.help
--no-includesDon't generate include statements for included schemas the generated file depends on (C++, Python, Proto-to-Fbs).help
--gen-mutableGenerate accessors that can mutate buffers in-place.help
--gen-onefileGenerate a single output file for C#, Go, Java, Kotlin and Python.help
--gen-name-stringsGenerate type name functions for C++ and Rust.help
--gen-object-apiGenerate an additional object-based API.help
--gen-compareGenerate operator== for object-based API types.help
--gen-nullableAdd Clang _Nullable for C++ pointer.help
--java-package-prefixAdd a prefix to the generated package name for Java.help
--java-checkerframeworkAdd @Pure for Java.help
--gen-generatedAdd @Generated annotation for Java.help
--gen-jvmstaticAdd @JvmStatic annotation for Kotlin methods in companion object for interop from Java to Kotlin.help
--gen-allGenerate not just code for the current schema files, but for all files it includes as well.help
--gen-json-emitGenerates encoding code which emits Flatbuffers into JSONhelp
--cpp-includeAdds an #include in generated file.help
--cpp-ptr-type TSet object API pointer type (default std::unique_ptr).help
--cpp-str-type TSet object API string type (default std::string).help
--cpp-str-flex-ctorDon't construct custom string types by passing std::string from Flatbuffers, but (char* + length).help
--cpp-field-case-style STYLEGenerate C++ fields using selected case style.help
--cpp-std CPP_STDGenerate a C++ code using features of selected C++ standard.help
--cpp-static-reflectionWhen using C++17, generate extra code to provide compile-time (static) reflection of Flatbuffers types.help
--go-namespaceGenerate the overriding namespace in Golang.help
--go-import IMPORTGenerate the overriding import for flatbuffers in Golang (default is "github.com/google/flatbuffers/go").help
--go-module-namePrefix local import paths of generated go code with the module namehelp
--raw-binaryAllow binaries without file_identifier to be read.help
--size-prefixedInput binaries are size prefixed buffers.help
--proto-namespace-suffix SUFFIXAdd this namespace to any flatbuffers generated from protobufs.help
--oneof-unionTranslate .proto oneofs to flatbuffer unions.help
--keep-proto-idKeep protobuf field ids in generated fbs file.help
--proto-id-gapAction that should be taken when a gap between protobuf ids found.help
--grpcGenerate GRPC interfaces for the specified languages.help
--schemaSerialize schemas instead of JSON (use with -b).help
--bfbs-filenames PATHSets the root path where reflection filenames in reflection.fbs are relative to.help
--bfbs-absolute-pathsUses absolute paths instead of relative paths in the BFBS output.help
--bfbs-commentsAdd doc comments to the binary schema files.help
--bfbs-builtinsAdd builtin attributes to the binary schema files.help
--bfbs-gen-embedGenerate code to embed the bfbs schema to the source.help
--conform FILESpecify a schema the following schemas should be an evolution of.help
--conform-includes PATHInclude path for the schema given with --conform PATHhelp
--filename-suffix SUFFIXThe suffix appended to the generated file names (Default is '_generated').help
--filename-ext EXTThe extension appended to the generated file names.help
--include-prefix PATHPrefix this PATH to any generated include statements.help
--keep-prefixKeep original prefix of schema include statement.help
--reflect-typesAdd minimal type reflection to code generation.help
--reflect-namesAdd minimal type/name reflection.help
--rust-serializeImplement serde::Serialize on generated Rust types.help
--rust-module-root-fileGenerate rust code in individual files with a module root file.help
--root-type TSelect or override the default root_type.help
--force-defaultsEmit default values in binary output from JSONhelp
--force-emptyWhen serializing from object API representation, force strings and vectors to empty rather than null.help
--force-empty-vectorsWhen serializing from object API representation, force vectors to empty rather than null.help
--flexbuffersUsed with "binary" and "json" options, it generates data using schema-less FlexBuffers.help
--no-warningsInhibit all warnings messages.help
--warnings-as-errorsTreat all warnings as errors.help
--cs-global-aliasPrepend "global::" to all user generated csharp classes and structs.help
--cs-gen-json-serializerAllows (de)serialization of JSON text in the Object API.help
--json-nested-bytesAllow a nested_flatbuffer field to be parsed as a vector of bytes in JSON, which is unsafe unless checked by a verifier afterwards.help
--ts-flat-files(deprecated) Alias for --gen-all.help
--ts-entry-points(deprecated) Alias for --gen-all.help
--annotate-sparse-vectorsDon't annotate every vector element.help
--annotate SCHEMAAnnotate the provided BINARY_FILE with the specified SCHEMA file.help
--no-leak-private-annotationPrevents multiple type of annotations within a Fbs SCHEMA file.help
--python-no-type-prefix-suffixSkip emission of Python functions that are prefixed with typenameshelp
--python-typingGenerate Python type annotationshelp
--python-versionGenerate code for the given Python version.help
--python-decode-obj-api-stringsDecode bytes to strings for the Python Object APIhelp
--python-gen-numpyWhether to generate numpy helpers.help
--ts-omit-entrypointOmit emission of namespace entrypoint filehelp
--file-names-onlyPrint out generated file names without writing to the fileshelp
--grpc-filename-suffix SUFFIXThe suffix for the generated file names (Default is '.fb').help
--grpc-additional-headerAdditional headers to prepend to the generated files.help
--grpc-use-system-headersUse <> for headers included from the generated code.help
--grpc-search-path PATHPrefix to any gRPC includes.help
--grpc-python-typed-handlersThe handlers will use the generated classes rather than raw bytes.help
--grpc-callback-apiGenerate gRPC code using the callback (reactor) API instead of legacy sync/async.help

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.