To publish a Unity game online, build it for the Web, then serve the complete generated build output from a web server or hosting service. In Unity 6, start at File > Build Profiles > Web. Preview with Unity’s Build and Run workflow, configure compression headers to match your build, and test the hosted URL in the browsers and devices you intend to support.
What “export for the web” means
A Unity Web build is the browser-ready output produced from your project; it is not the Unity project source. Exporting alone does not put the game online: the generated files must be served by a web server or hosting service. Unity’s Web publishing guidance covers deployment approaches and configuration examples for Nginx, Apache, and IIS: Unity Web deployment.
As an Amazon Associate I earn from qualifying purchases.
How do I build a Unity game for the web?
- Prepare the release content. Confirm which scenes and assets belong in the release, remove test-only content, and decide which browsers and devices you will support. Compatibility and performance depend on the project’s features and target hardware.
- Select the Web platform. In Unity 6, open File > Build Profiles, select Web, and review the Web build options. Unity documents browser selection, texture compression, development-build controls, and code-optimization choices in its Unity 6 Web build settings.
- Choose settings for the task. Use a development build while debugging or profiling. For a release, choose code optimization based on whether you need faster iteration, greater runtime speed, or a smaller download. The available choices involve trade-offs; no setting guarantees a particular performance or load-time improvement for every project.
- Build and preview locally. Choose a named output location and use Build and Run to preview the Web player. Unity’s workflow serves the build locally; opening the generated HTML file directly is not a reliable substitute, because browser security rules can block local-file loading. See Unity’s Web build workflow.
Older Unity tutorials may show Build Settings and a separate Switch Platform control. Those labels describe an older editor interface; for Unity 6, use Build Profiles rather than mixing the two sets of instructions.
Which browsers and devices should you target?
Unity 6’s desktop Web requirements call for a browser that supports WebGL 2.0, HTML5 standards, 64-bit operation, and WebAssembly. Unity lists current versions of Chrome, Firefox, Safari, and Chromium-based Edge for desktop operating systems. The Unity 6 system requirements also describe mobile browser requirements, but meeting a requirement does not establish that a particular game works well on a given device.
#1 Best Overall
Treat mobile as a separate test target. Check the actual game on representative phones and tablets, as well as the desktop browsers you plan to support. Input, audio, network behavior, startup, and memory use can vary by project and device; Unity’s general requirements do not certify your build’s performance.
How should you choose compression and code optimization?
Compression controls the size of files sent to players and affects the server configuration needed for native browser decompression. Unity’s Web Publishing Settings describe gzip, Brotli, and disabled compression: Unity Web publishing and compression.
Rank #2
| Choice | Download and build trade-off | Server consideration |
|---|---|---|
| Gzip | Unity identifies gzip as a default option that builds faster and has broad native browser support over HTTP and HTTPS. | For native decompression, serve the files with response headers that match the compression format. |
| Brotli | Generally produces smaller compressed files than gzip, but takes longer to compress. | Chrome and Firefox support native Brotli over HTTPS. Configure matching response headers if relying on native decompression. |
| Disabled | No compression is applied by this Unity setting, so there is no compression-format trade-off here. | No compression-specific Content-Encoding header is required for these uncompressed files. |
Unity’s code-optimization choices similarly balance build iteration against runtime speed and disk size. Pick the option that fits your release goal, then assess the actual build rather than assuming a fixed gain.
Recommended Free Tools
Quick Recap
Best Value
Rank #4
How do I publish a Unity Web build?
- Build the final output. Use the Web profile and release settings you intend to deploy. Keep the generated directory structure intact.
- Upload or copy the complete output. Place the generated Web build files on your web server or hosting service; do not upload only the HTML entry file. Follow the configuration method for your server. Unity’s deployment documentation includes approaches for Nginx, Apache, and IIS.
- Match server responses to compression. If using gzip or Brotli for native browser decompression, configure the server to return the appropriate
Content-Encodingresponse header. Unity states: “To let the browser handle decompression natively, you need to configure your web server to serve the compressed files with the appropriate http headers.” - Open the deployed URL and test. Test the production URL in your target browsers and on representative devices. Check browser developer tools for loading failures, MIME-type problems, and missing or incorrect headers; then test startup, controls, audio, network behavior, and memory.
Why does my Unity Web build fail to load?
- It works locally but not at the hosted URL: confirm the complete generated output was uploaded and its directory structure preserved. Check the browser console and network panel for failed requests.
- The build uses compression but the server does not: confirm the server’s
Content-Encodingresponse matches the build’s compression format. With missing or incorrect headers, native browser decompression may fail. Unity also documents a JavaScript decompression fallback in its Web compression guidance. - The page was opened as a local file: use Build and Run or a local web server instead. Direct file opening can run into browser security restrictions.
- Only some browsers or devices fail: compare the failing environment with Unity’s Web requirements, then test the project on the actual target hardware. General browser capability requirements alone cannot identify a project-specific compatibility or performance issue.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




