Incompatibility between 4.2.0 and preview in the handling of base64-encoded data URLs for glTF


As at 2021-06-28, there is some variation across versions in how Babylon.js handles the loading of base-64 encoded glTF data from data URLs.

Version 4.2.0 of Babylon.js does not accept data URLs of the form data:;base64,ABC....

Instead, the data URL must either exclude the semicolon (data:base64,ABC...), or must explicitly specify the mime type followed by a semicolon (data:application/octet-stream;base64,ABC...).

In contrast, the preview version of Babylon.js requires a semicolon (data:;base64,ABC...) or an explicit mime type plus a semicolon. Without the semicolon, the glTF doesn’t load (JSON parsing error).



This issue matters to me because a tool that I created used the semicolon-less approach to generate HTML reports containing inline glTF models while also using the preview version of Babylon.js to render the models in the browser.

Everything was peachy until recently when the models stopped loading because of the semicolon issue, presumably when the code around base64 data URLs was tightened up. I’m kicking myself because if I’d only specified a mime-type then everything would have been fine. Duh.

If I had access to the broken reports then I’d just write a script to fix them, but the reports are generated by customers. Double duh.


I’ve marked this a bug, but that’s not really fair because all you have done is improve your compliance with RFC 2397.

I guess I’m just hoping that you’ll take pity on me and add a special case to the base64 parser in preview to accommodate the 4.2.0 semicolon-less behavior.

Adding our friend @bghgary who heavily work on the base64 rewrite :slight_smile:

Yes, we updated this recently and you are right that it was incorrect before.

I will restore the wrong way of doing it for backcompat. Sorry for the troubles.

Awesome! You have really saved my ass on this one. You are indeed a Jedi master.

1 Like

I was hoping no one was actually depending on this wrongly formatted base64 :slight_smile:


PR: Restore invalid baes64 glb format for backcompat by bghgary · Pull Request #10584 · BabylonJS/Babylon.js (


This will be in the next nightly in a couple hours.

1 Like

Now that’s what I call service! Thanks a million.

Will you guys close out the bug, or do I need to verify the resolution?

1 Like

I ll close it as soon as it ships nw

1 Like