BabylonJS/Babylon.js · error · Error
Unexpected content format: ${contentFormat}
Error message
Unexpected content format: ${contentFormat} What it means
Thrown while unpacking a glTF binary v1 container when the first chunk's contentFormat uint32 is not ContentFormat.JSON (0). glTF-Binary v1 requires the initial content chunk to be JSON.
Source
Thrown at packages/dev/loaders/src/glTF/glTFFileLoader.pure.ts:1307
}
}
this._endPerformanceCounter("Unpack Binary");
return unpacked;
});
}
private _unpackBinaryV1Async(dataReader: DataReader, length: number): Promise<IGLTFLoaderData> {
const ContentFormat = {
JSON: 0,
};
const contentLength = dataReader.readUint32();
const contentFormat = dataReader.readUint32();
if (contentFormat !== ContentFormat.JSON) {
throw new Error(`Unexpected content format: ${contentFormat}`);
}
const bodyLength = length - dataReader.byteOffset;
const data: IGLTFLoaderData = { json: this._parseJson(dataReader.readString(contentLength)), bin: null };
if (bodyLength !== 0) {
const startByteOffset = dataReader.byteOffset;
data.bin = {
readAsync: (byteOffset, byteLength) => dataReader.buffer.readAsync(startByteOffset + byteOffset, byteLength),
byteLength: bodyLength,
};
}
return Promise.resolve(data);
}
private _unpackBinaryV2Async(dataReader: DataReader, length: number): Promise<IGLTFLoaderData> {
const ChunkFormat = {
View on GitHub (pinned to 0592b347b8)
Solutions
- Convert the legacy .glb to glTF 2.0 (gltf-pipeline) so the modern v2 path is used
- Fix the chunk header so contentFormat is 0 (JSON)
- Re-export with a compliant tool and validate with glTF-Validator
Defensive patterns
Strategy: validation
Validate before calling
const dv = new DataView(await file.arrayBuffer());
if (dv.getUint32(0, true) !== 0x46546c67) throw new Error('not glb');
if (dv.getUint32(4, true) === 1) {
const fmt = dv.getUint32(16, true);
if (fmt !== 0) throw new Error('glb-v1 first chunk is not JSON: ' + fmt);
} Try / catch
try {
await loader.loadAsync(url);
} catch (e) {
if (e.message?.startsWith('Unexpected content format')) {
console.error('Legacy glb-v1 with non-JSON first chunk — convert to glTF 2.0:', e.message);
}
} Prevention
- Migrate legacy glb-v1 assets to glTF 2.0
- Never hand-edit binary chunk headers
- Validate all binaries in CI with glTF-Validator
When it happens
Trigger: Loading a legacy glb-v1 file whose first chunk format field is wrong or corrupted.
Common situations: Very old exporter output; files hand-mangled or re-chunked by custom tooling; confusing v1 containers with v2 chunk layouts.
Related errors
- GLTFLoaderUnexpectedMagicError
- First chunk format is not JSON
- Unexpected JSON chunk
- Expected opening { after type & name
- Expected OFFSET, but got:
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/ca65a0869aeb5c02.
Report an issue: GitHub.