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)
| Option | Description | Source |
|---|---|---|
-b, --binary | Generate wire format binaries for any data definitions | help |
-c, --cpp | Generate C++ headers for tables/structs | help |
-n, --csharp | Generate C# classes for tables/structs | help |
-d, --dart | Generate Dart classes for tables/structs | help |
-g, --go | Generate Go files for tables/structs | help |
-j, --java | Generate Java classes for tables/structs | help |
-t, --json | Generate text output for any data definitions | help |
--jsonschema | Generate Json schema | help |
--kotlin | Generate Kotlin classes for tables/structs | help |
--kotlin-kmp | Generate Kotlin multiplatform classes for tables/structs | help |
--lobster | Generate Lobster files for tables/structs | help |
-l, --lua | Generate Lua files for tables/structs | help |
--nim | Generate Nim files for tables/structs | help |
--php | Generate PHP files for tables/structs | help |
--proto | Input is a .proto, translate to .fbs | help |
-p, --python | Generate Python files for tables/structs | help |
-r, --rust | Generate Rust files for tables/structs | help |
--swift | Generate Swift files for tables/structs | help |
-T, --ts | Generate TypeScript code for tables/structs | help |
-o PATH | Prefix PATH to all generated files. | help |
-I PATH | Search for includes in the specified path. | help |
-M | Print make rules for generated files. | help |
--version | Print the version number of flatc and exit. | help |
-h, --help | Prints this help text and exit. | help |
--strict-json | Strict JSON: field names must be / will be quoted, no trailing commas in tables/vectors. | help |
--allow-non-utf8 | Pass non-UTF-8 input through parser and emit nonstandard \x escapes in JSON. | help |
--natural-utf8 | Output strings with UTF-8 as human-readable strings. | help |
--defaults-json | Output fields whose value is the default when writing JSON | help |
--unknown-json | Allow fields in JSON that are not defined in the schema. | help |
--no-prefix | Don't prefix enum values with the enum type in C++. | help |
--scoped-enums | Use C++11 style scoped and strongly typed enums. | help |
--no-emit-min-max-enum-values | Disable generation of MIN and MAX enumerated values for scoped enums and prefixed enums. | help |
--swift-implementation-only | Adds a @_implementationOnly to swift imports | help |
--gen-includes | (deprecated), this is the default behavior. | help |
--no-includes | Don't generate include statements for included schemas the generated file depends on (C++, Python, Proto-to-Fbs). | help |
--gen-mutable | Generate accessors that can mutate buffers in-place. | help |
--gen-onefile | Generate a single output file for C#, Go, Java, Kotlin and Python. | help |
--gen-name-strings | Generate type name functions for C++ and Rust. | help |
--gen-object-api | Generate an additional object-based API. | help |
--gen-compare | Generate operator== for object-based API types. | help |
--gen-nullable | Add Clang _Nullable for C++ pointer. | help |
--java-package-prefix | Add a prefix to the generated package name for Java. | help |
--java-checkerframework | Add @Pure for Java. | help |
--gen-generated | Add @Generated annotation for Java. | help |
--gen-jvmstatic | Add @JvmStatic annotation for Kotlin methods in companion object for interop from Java to Kotlin. | help |
--gen-all | Generate not just code for the current schema files, but for all files it includes as well. | help |
--gen-json-emit | Generates encoding code which emits Flatbuffers into JSON | help |
--cpp-include | Adds an #include in generated file. | help |
--cpp-ptr-type T | Set object API pointer type (default std::unique_ptr). | help |
--cpp-str-type T | Set object API string type (default std::string). | help |
--cpp-str-flex-ctor | Don't construct custom string types by passing std::string from Flatbuffers, but (char* + length). | help |
--cpp-field-case-style STYLE | Generate C++ fields using selected case style. | help |
--cpp-std CPP_STD | Generate a C++ code using features of selected C++ standard. | help |
--cpp-static-reflection | When using C++17, generate extra code to provide compile-time (static) reflection of Flatbuffers types. | help |
--go-namespace | Generate the overriding namespace in Golang. | help |
--go-import IMPORT | Generate the overriding import for flatbuffers in Golang (default is "github.com/google/flatbuffers/go"). | help |
--go-module-name | Prefix local import paths of generated go code with the module name | help |
--raw-binary | Allow binaries without file_identifier to be read. | help |
--size-prefixed | Input binaries are size prefixed buffers. | help |
--proto-namespace-suffix SUFFIX | Add this namespace to any flatbuffers generated from protobufs. | help |
--oneof-union | Translate .proto oneofs to flatbuffer unions. | help |
--keep-proto-id | Keep protobuf field ids in generated fbs file. | help |
--proto-id-gap | Action that should be taken when a gap between protobuf ids found. | help |
--grpc | Generate GRPC interfaces for the specified languages. | help |
--schema | Serialize schemas instead of JSON (use with -b). | help |
--bfbs-filenames PATH | Sets the root path where reflection filenames in reflection.fbs are relative to. | help |
--bfbs-absolute-paths | Uses absolute paths instead of relative paths in the BFBS output. | help |
--bfbs-comments | Add doc comments to the binary schema files. | help |
--bfbs-builtins | Add builtin attributes to the binary schema files. | help |
--bfbs-gen-embed | Generate code to embed the bfbs schema to the source. | help |
--conform FILE | Specify a schema the following schemas should be an evolution of. | help |
--conform-includes PATH | Include path for the schema given with --conform PATH | help |
--filename-suffix SUFFIX | The suffix appended to the generated file names (Default is '_generated'). | help |
--filename-ext EXT | The extension appended to the generated file names. | help |
--include-prefix PATH | Prefix this PATH to any generated include statements. | help |
--keep-prefix | Keep original prefix of schema include statement. | help |
--reflect-types | Add minimal type reflection to code generation. | help |
--reflect-names | Add minimal type/name reflection. | help |
--rust-serialize | Implement serde::Serialize on generated Rust types. | help |
--rust-module-root-file | Generate rust code in individual files with a module root file. | help |
--root-type T | Select or override the default root_type. | help |
--force-defaults | Emit default values in binary output from JSON | help |
--force-empty | When serializing from object API representation, force strings and vectors to empty rather than null. | help |
--force-empty-vectors | When serializing from object API representation, force vectors to empty rather than null. | help |
--flexbuffers | Used with "binary" and "json" options, it generates data using schema-less FlexBuffers. | help |
--no-warnings | Inhibit all warnings messages. | help |
--warnings-as-errors | Treat all warnings as errors. | help |
--cs-global-alias | Prepend "global::" to all user generated csharp classes and structs. | help |
--cs-gen-json-serializer | Allows (de)serialization of JSON text in the Object API. | help |
--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. | help |
--ts-flat-files | (deprecated) Alias for --gen-all. | help |
--ts-entry-points | (deprecated) Alias for --gen-all. | help |
--annotate-sparse-vectors | Don't annotate every vector element. | help |
--annotate SCHEMA | Annotate the provided BINARY_FILE with the specified SCHEMA file. | help |
--no-leak-private-annotation | Prevents multiple type of annotations within a Fbs SCHEMA file. | help |
--python-no-type-prefix-suffix | Skip emission of Python functions that are prefixed with typenames | help |
--python-typing | Generate Python type annotations | help |
--python-version | Generate code for the given Python version. | help |
--python-decode-obj-api-strings | Decode bytes to strings for the Python Object API | help |
--python-gen-numpy | Whether to generate numpy helpers. | help |
--ts-omit-entrypoint | Omit emission of namespace entrypoint file | help |
--file-names-only | Print out generated file names without writing to the files | help |
--grpc-filename-suffix SUFFIX | The suffix for the generated file names (Default is '.fb'). | help |
--grpc-additional-header | Additional headers to prepend to the generated files. | help |
--grpc-use-system-headers | Use <> for headers included from the generated code. | help |
--grpc-search-path PATH | Prefix to any gRPC includes. | help |
--grpc-python-typed-handlers | The handlers will use the generated classes rather than raw bytes. | help |
--grpc-callback-api | Generate gRPC code using the callback (reactor) API instead of legacy sync/async. | help |