To export a Unity WebGL build you switch your project to the WebGL platform, adjust a handful of player and publishing settings, then hit Build so Unity compiles your game into WebAssembly that runs in any modern browser. This guide walks through every step with the exact menus and settings, and shows you how to test the build locally before you publish it.
Before You Start: Install WebGL Build Support
WebGL is a separate build module, not something bundled with the base editor. Open Unity Hub → Installs, click the gear icon on your editor version, choose Add Modules, and tick WebGL Build Support. Without this module the WebGL platform is greyed out and you will waste an hour wondering why.
WebGL always compiles through IL2CPP (it converts your C# to C++ then to WebAssembly), so the first build is slow — expect several minutes even on a fast machine. Subsequent builds are cached and much faster.
Step 1 — Switch Your Platform to WebGL
Open File → Build Settings (in Unity 6 this is File → Build Profiles). Select WebGL from the platform list and click Switch Platform. Unity will reimport your textures and shaders for the web target, which can take a while on a large project.
While you are here, add your scenes to the Scenes In Build list in the order they should load. The scene at index 0 is your entry point.
Step 2 — Configure Player Settings for WebGL
Click Player Settings in the Build window, then open the WebGL tab. The settings that matter most:
- Resolution and Presentation — set a Default Canvas Width / Height that matches your game (for example 960 × 600). Pick a WebGL Template: *Default* is a plain page, *Minimal* strips the branding, and *PWA* adds an installable manifest.
- Other Settings → Color Space — *Linear* looks better but requires WebGL 2.0. *Gamma* is more compatible with old hardware. Most modern games use Linear.
- Other Settings → Managed Stripping Level — set this to High to strip unused engine code and shrink the download. Combine with Strip Engine Code enabled.
- Other Settings → Enable Exceptions — set to Explicitly Thrown Exceptions Only for release. *Full* is huge and slow; use it only while debugging.
Turn off the Development Build checkbox in Build Settings for your final export — it disables debug overhead and makes the build noticeably smaller.
Step 3 — Set Publishing (Compression) Settings
Still in the WebGL Player Settings, open Publishing Settings. This is where you control download size:
- Compression Format — choose Brotli for the smallest files. Brotli needs an HTTPS host that sends the right
Content-Encodingheader. If you cannot control server headers, use Gzip or enable Decompression Fallback, which lets the browser unpack the file itself at the cost of a larger download. - Data Caching — enable it so returning players load from the browser cache instead of re-downloading the whole game.
- Debug Symbols — set to Off (or *External*) for release builds to save space.
Step 4 — Build and Test in the Browser
Back in Build Settings, click Build (or Build And Run). Choose an empty folder — Unity fills it with the finished site. Build And Run is the easiest way to test because Unity launches a temporary local web server for you and opens your browser automatically.
Do not double-click index.html from your file explorer. Opening it via file:// breaks fetch requests and compression, and you will see an endless loading bar. Always serve it over HTTP. A quick option is to open a terminal in the build folder and run:
``` python -m http.server 8000 ```
Then visit http://localhost:8000. If the game loads, plays, and audio works, your export is good. If it hangs on the loading bar, check the browser console (F12) — see our guide on fixing a Unity WebGL build that won't load.
What's Inside the Build Folder
A finished export contains three things you must upload together:
- index.html — the page that boots your game.
- Build/ — the heavy files:
.loader.js,.framework.js, the.wasmcode, and the.dataasset bundle (possibly.bror.gzif compressed). - TemplateData/ — styling and icons for the loading page.
Keep the folder structure intact. If the Build/ folder ends up in the wrong place, the loader can't find its files and nothing runs.
Publish Your WebGL Game
Once the build runs cleanly on localhost, you're ready to share it. On The Gaming Nest you can upload this exact folder and get an instant, no-download page that players across the Arab world can open in one click — see how to publish a WebGL game. If your .data file feels heavy, trim it first with our tips on reducing Unity WebGL build size, then publish and start collecting plays.