Can Unity export to HTML5?
Yes. Unity has a Web build target, called WebGL in older versions. Unity compiles your C# code to WebAssembly, and the game renders with WebGL 2. The result is an HTML page with a loader and compressed build files that you can host on any web server.
Unity 6 added official support for mobile browsers: iOS Safari 15 and newer and Chrome 58 and newer on Android. On desktop you need a browser with WebGL 2 and 64-bit WebAssembly. So the export itself is rarely the problem. The hard part is a build that is small, stable and fast enough for real players.
Path 1: ship an optimized Unity WebGL build
This path keeps your code, scenes and tools. It fits when the game is light enough for the place where you publish it, or when you can make it light enough.
- Build size. Release builds without development options, code optimized for disk size, managed code stripping and Brotli compression on a server that serves it correctly. Unity lists these settings in its guide to optimizing Web builds.
- Assets and loading. Texture compression that the target devices support, lighter audio and content that loads later with Addressables or asset bundles, so players reach the first scene quickly.
- Memory. A browser tab gets far less memory than a native app, and a crash during loading is a common problem on phones. We profile the heap and the largest textures on real devices. Unity itself recommends iOS Safari 18.2 or newer because of its higher memory limit.
- Plugins and SDKs. Native Android and iOS plugins do not run in the browser. Ads, analytics, saves, purchases and login need web versions, usually JavaScript plugins (.jslib) and the SDK of the portal you publish on.
- Input and audio. Mouse and keyboard controls next to touch, and audio that starts after the first tap or click, because browsers block sound before the player interacts with the page.
- Portal requirements. Web portals publish their own rules. CrazyGames, for example, asks for an initial download of 50 MB or less in a basic implementation. Poki has its own developer documentation for the SDK, testing and onboarding.
Checklist: reduce the Unity WebGL build size
- Turn off Development Build for the release build.
- Set Code Optimization to Disk Size with LTO. Unity also offers Maximum Size Reduction, which you should test for performance.
- Set Managed Stripping Level to High and keep a link.xml file for code that runs through reflection.
- Turn on Strip Engine Code.
- Use Brotli compression and serve the game over HTTPS, because Chrome and Firefox support Brotli natively only there.
- Compress textures with formats the target devices support and lower their resolution where players will not notice.
- Move content the first level does not need into Addressables.
- Remove unused packages and plugins, then check the build report for the largest assets.
Unity collects more tips for phones in its page on optimizing the Web platform for mobile.
Path 2: rewrite the game in Defold
Sometimes the Unity build stays too large or too slow after all the optimization. We see this most often with 2D and light 3D games that must open in a few seconds on older phones or pass a strict portal limit.
In that case we rebuild the runtime in Defold and keep what players see: the design, the art, the audio, the levels and the balance data. The C# gameplay code is rewritten in Lua. Defold has a small engine, you can leave out the engine features a game does not use, and one project builds for the web, iOS, Android and desktop. We describe the steps in our guide to porting a Unity game to Defold.
Our team includes experienced Unity and C# developers, and we have moved mobile games of well-known brands from Unity to Defold for the web. That helps us read the original project quickly and keep the game feel the same.
How we choose between the two paths
We start with a short audit of the project and a test build in a real browser. Then we compare the result with your target.
- Stay in Unity when the build fits the portal limits after optimization, the game relies on 3D or Unity features that are hard to rebuild, or your team will keep developing it in Unity.
- Move to Defold when the game is 2D or light 3D, the first download must be small, older phones matter, or you want one lighter project for web and mobile.
- Look at the business side too. Where you will publish, how players will find the game and how it will earn money. Our web porting service page covers the wider process for Unity, Godot and Construct games.
Before production starts, you get a written recommendation with the risks of each path.
Unity games already in the browser
Subway Surfers is a Unity game, and its official web version runs on Poki with arrow keys on desktop and swipes on phones. More ports are in our examples of mobile games ported to the browser.
How to put a Unity game on your website
A Unity Web build is a folder with an HTML file, a loader script and the compressed build files. You can host it on your own server or a CDN and embed it in a page with an iframe. The server must send the right Content-Encoding header for Brotli or gzip files, as Unity explains in its deployment guide. Use HTTPS, and test the page on a phone before you share the link.
What you get
- An audit with the recommended path and the main risks.
- A first test build in the browser early in the project.
- A release build tuned for your website or target portal, with the portal SDK in place.
- Tests on desktop and mobile browsers, older phones included.
- The full source project and build instructions.
Work with Codeward
Codeward is a game studio from Kraków with many client projects behind it. We port games to the browser from Unity, Godot, Construct and other engines. Send us a link to a build or a short description of your Unity game, and we will tell you which path makes sense for it.