tinygltf v3 trades the C++ loader for three C files and one arena
Header only C11 tiny glTF 2.0 library
At a glance
- What is it?
- tinygltf v3 is a C11 implementation of a glTF 2.0 loader and writer that you copy into a project as three files, with every parse-time allocation coming from a single arena and one free call. The README also documents four build systems, an opt-out switch for index validation, and an empty Builds heading that stayed empty after the rewrite.
- Who is it for?
- tinygltf v3 suits C projects that want glTF 2.0 reading and writing without a C++ toolchain, and it is a poor match for codebases still written against the old tiny_gltf.h interface, which has been deprecated and parked in attic/ without being built or tested. Two decisions deserve a look before you adopt it.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 15 days ago.
- What is it written in?
- Mainly HTML, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.
Star history
- syoyo/tinygltf2,559 ★ · +22
| Repository | 2026-10-01 | 2026-11-22 |
|---|---|---|
| syoyo/tinygltf | 2.5k | 2.6k |
22 Stars in the last 52 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Three files to copy, and one define decides whether stdio is used
There is no install step. The quick start is to copy tiny_gltf_v3.h, tiny_gltf_v3.c and tinygltf_json_c.h into your project and compile tiny_gltf_v3.c as C11 or newer. Two opt-in defines control what the runtime is allowed to touch: TINYGLTF3_ENABLE_FS turns on stdio-backed filesystem helpers so that tg3_parse_file() can read from disk, and TINYGLTF3_ENABLE_STB_IMAGE turns on the image loader. Both are off by default, which means a default build does no file or image I/O and the caller decides when and how assets are loaded. For compatibility, the legacy TINYGLTF3_IMPLEMENTATION include path remains available even though the C++ implementation is deprecated. The API surface is plain C data: no STL, no RTTI and no exceptions are required, which is the stated reason it is easy to bind to other languages. The single include is all a translation unit needs to start.
An arena owns every parse-time allocation
Memory management is the headline design decision. Every allocation made while parsing comes out of a single arena, so the model graph, its strings and its buffers share one owner rather than arriving as a tree of individually freed nodes. The consequence is one call at the end of the documented sample:
tg3_model_free(&model);The README states plainly that a single tg3_model_free() call frees everything. That claim is scoped to the model, though, and the same sample shows what sits beside it: the error stack is a separate object with its own tg3_error_stack_free() call. Read as a whole, the sample leaves a caller with two structures to initialise before parsing and two to release afterwards, one of which exists whether or not the parse succeeded. The header warns that error strings can be arena-allocated and become invalid when the model is freed. Read or copy them before calling tg3_model_free(); bindings must preserve this lifetime as well as freeing both structures.
The error stack carries severity, message and source location
Errors are not a single integer with a message. tg3_error_stack is machine-readable, with severity levels and source locations attached to each entry, and the documented failure path walks the whole stack rather than the first entry:
for (uint32_t i = 0; i < errors.count; i++) {
fprintf(stderr, "[%d] %s\\n", (int)errors.entries[i].severity,
errors.entries[i].message ? errors.entries[i].message : "(null)");
}Three details in those five lines matter for anything that parses files you did not write. The loop goes over errors.count rather than stopping at the first failure, so a malformed asset produces a report instead of a single complaint. The message field is treated as nullable, with a literal (null) fallback rather than a dereference. And severity is carried per entry, so a caller can filter warnings out of a log while keeping the errors. The test suite names error-message lifetime as one of its security regression cases, which tells you the lifetime of those message buffers is a deliberate contract rather than an accident of the allocator.
Index bounds validation is on by default and can be switched off
The v3 runtime describes itself as hardened against untrusted input, and the mechanisms are named. There is URI sanitization, there are strict numeric range checks, and there is post-parse index bounds validation which is default-on. That last one has an explicit opt-out, tg3_parse_options.validate_indices = 0, which is the single most consequential line in the README for anyone loading third-party models: setting it removes the pass that catches mesh indices pointing outside their buffers after the fact. The header also warns that URI sanitization does not confine filesystem access: for untrusted files, provide callbacks that restrict reads to a known directory. The validation claim is backed by a libFuzzer harness under tests/v3/fuzzer/, built with ASan and UBSan and run through make run, which produces the fuzz_gltf_v3_c binary. Crafted regression inputs are kept apart in tests/v3/security/ and seeded into the fuzzer corpus, so the malformed files found by the fuzzer become permanent test cases. The header itself carries a Security Considerations block at the top for readers who never open the README.
Three layers of coverage, five testers
The testing section opens by saying the v3 C runtime ships with three layers of automated coverage, then names five things. tests/tester_v3_c.c holds internal unit checks plus the security regression tests, including path traversal, a negative byteStride, out of bounds indices and the error-message lifetime, and it doubles as a command line tool that takes a single asset. tests/tester_v3_c_v1port.c is a port of the legacy unit tests to the v3 C API, kept for behavioural parity with the old C++ interface, which is the only thing in the repository that still guards against a change in one API quietly altering the other. tests/tester_v3_json_c.c and tests/tester_v3_freestanding.c cover the JSON backend and the freestanding build with no libc at all. The fifth is test_runner.py, a model verifier that runs the C tester against every model in the glTF-Sample-Models/2.0 collection and validates structured COUNTS and DIGEST output, which is how a change in parsing gets caught across a corpus instead of one file.
Four build paths documented, the root Makefile wraps one
The README gives four build recipes, and the difference between them is smaller than the list suggests, because all four compile the same three files:
make -C tests && make -C tests runcmake -B build && cmake --build build && ctest --test-dir build --output-on-failuremeson setup build && meson compile -C build && meson test -C buildThe fourth is the WebAssembly path, make -C web && make -C web sample, which needs an Emscripten SDK and looks for it at ~/work/emsdk by default; it builds the browser demo in web/ that renders glTF and GLB files with three.js behind a file picker and drag and drop. The root Makefile is worth reading separately, because it is only a convenience wrapper: its all target calls $(MAKE) -C tests all, test calls $(MAKE) -C tests run, and clean calls $(MAKE) -C tests clean. So make at the top of the repository builds the C testers and nothing else, and the CMake, Meson and Emscripten paths are never reached through it.
The C++ implementation is parked in attic/ and never built
v3 is a replacement, not an addition. The previous C++ implementation, with tiny_gltf.h, tiny_gltf.cc, tinygltf_json.h, json.hpp, loader_example.cc and the C++ examples and tests, is marked deprecated, moved into the attic/ directory for reference, and explicitly no longer built, tested or installed. Anything still calling the C++ API is therefore off the tested path, which is why the v1 port tester exists. Two smaller facts about the repository shape the same picture. The default branch is named release rather than main or master, and the releases are v3.0.1 on 2026-08-02, v3.0.0 on 2026-03-23 and v2.9.7 on 2025-11-02, with the last recorded push dated 2026-08-02, the same day as the newest tag. GitHub also classifies this repository as HTML rather than C, while the shipped library is C11 first, with C17 and C++17 as the stated defaults and an optional C++20 coroutine facade that is auto-detected.
An empty Builds heading sits above a three-way licence stack
Two loose ends in the README are worth naming. The document has a Builds heading with nothing under it at all, which is the kind of leftover that tells you the section list was carried across from the previous version of the file. And the licensing is not one line but a stack: TinyGLTF is MIT, while the v3 runtime carries fast_float for JSON number parsing and dragonbox for JSON number serialization inside tinygltf_json_c.h, the first under Apache 2.0, MIT or Boost 1.0 and the second under Apache 2.0 with LLVM exceptions or Boost 1.0, plus stb_image.h as an optional public domain image loader behind TINYGLTF3_ENABLE_STB_IMAGE. The tree also carries an AGENTS.md beside the source files, a benchmark/ directory, an in-tree models/ directory and .clang-format, so the repository is arranged for agents and for measurement as well as for building the library itself.
Editorial conclusion
tinygltf v3 suits C projects that want glTF 2.0 reading and writing without a C++ toolchain, and it is a poor match for codebases still written against the old tiny_gltf.h interface, which has been deprecated and parked in attic/ without being built or tested. Two decisions deserve a look before you adopt it. Index bounds validation runs after parsing and can be disabled with tg3_parse_options.validate_indices = 0, so leave it on unless you have a reason not to. And the library ships with filesystem and image access switched off, which means the loading path you test is not the path most callers end up enabling. Build it with the toolchain you already have, since all four documented paths cover the same three files, and pin a version: the tags stop at v3.0.1.
Frequently asked questions
how to use tinygltf
Copy tiny_gltf_v3.h, tiny_gltf_v3.c and tinygltf_json_c.h into your project and compile tiny_gltf_v3.c as C11 or newer. For tg3_parse_file(), define TINYGLTF3_ENABLE_FS at build time to use the stdio helpers, or supply filesystem callbacks. Initialise the model and error stack, inspect errors before freeing the model, then release both structures.
How does tinygltf v3 manage memory?
The model uses an arena released by tg3_model_free(); the error stack also has tg3_error_stack_free(). Error message strings can belong to the model arena, so read or copy them before freeing the model. Follow the documented initialization and cleanup sequence even when parsing fails.
Does tinygltf v3 read files and images by default?
No. TINYGLTF3_ENABLE_FS and TINYGLTF3_ENABLE_STB_IMAGE are off by default, so filesystem helpers and the image loader are compiled in only when you define them while building tiny_gltf_v3.c.
How does tinygltf v3 check model indices?
With post-parse index bounds validation, which is on by default and can be disabled by setting tg3_parse_options.validate_indices = 0. URI sanitization and strict numeric range checks are also part of the runtime, exercised by a libFuzzer harness built with ASan and UBSan.
What happened to the C++ version of tinygltf?
It is deprecated. The C++ implementation, including tiny_gltf.h, tiny_gltf.cc and json.hpp, has been moved to attic/ for reference and is no longer built, tested or installed. TinyGLTF v3 in C is the mainline.
Which build systems does tinygltf v3 support?
Four documented paths: plain make in tests/, CMake with ctest, Meson, and WebAssembly through Emscripten with make -C web. The root Makefile is a convenience wrapper whose targets only delegate to the tests directory.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/syoyo-tinygltf)Star history chart for your README
[](https://hysenlabs.com/projects/syoyo-tinygltf)Was this useful?