s&box
RustCounter-Strike 2s&boxDeadlock
Wiki
Get s&box on Steam
Browse
OverviewGetting StartedCreating GamesEngine & ToolsDocumentationCommunity GamesResources
s&boxDocumentationAssetsResourcesBinary Serialization
SOURCE 2 · C#
Build and play games with s&box.

Facepunch's game engine and creation platform — make games in C#, or jump straight into community games.

Get s&box on Steam

s&box Wiki

  • Overview
  • Getting Started
  • Creating Games
  • Engine & Tools
  • Documentation
  • Community Games
  • Resources

Tools & Community

  • Getting Started
  • Creating Games
  • Engine & Tools
  • Resources

Platforms

  • RustBattle
  • CSBattle
  • Rust Game Wiki
  • CS2 Skins Wiki
  • Deadlock Wiki

About

  • Official Site
  • Developer Wiki
  • GitHub
  • Get on Steam
NOT AFFILIATED WITH FACEPUNCH STUDIOS · © 2026 s&box Wiki (community)
Docs/Assets
Assets

Binary Serialization

If you find your JSON files growing too large, you can store data as a binary blob instead. This works with anything that serializes to JSON.

Creating a binary blob

Here's a snippet with a game resource that stores a list of positions in a companion binary blob while the rest is in clear JSON.

// Custom Asset that will serialize MyBinaryBlob as binary data
[AssetType( Name = "My CustomResource", Extension = "res", Category = "other" )]
public partial class CustomResource : GameResource
{
	public string Title { get; set; }

	public MyBigData Data = new();
}

// This will be stored as binary data according to Serialize & Deserialize method
public class MyBigData : BlobData
{
	public List<float> Data { get; set; } = [];

	public override void Serialize( ref Writer writer )
    {
		// This layout will be what we will be deserializing, plan accordingly
		writer.Stream.Write( Data.Count ); // int
		
		foreach ( var instance in Data )
		{
			writer.Stream.Write( instance );
		}
	}

	public override void Deserialize( ref Reader reader )
    {

		var instanceCount = reader.Stream.Read<int>(); // Int

		for ( int i = 0; i < instanceCount; i++ )
        {
			Data.Add( reader.Stream.Read<float>() );
		}
	}
}

Considerations

Working with binary files requires a bit more planning as it is not human readable. For example, deserializing a dynamic list is done by writing the size first so that we know how many elements to skip or read. Just like in the example above.

Source: Facepunch/sbox-docs (CC-BY-4.0) · updated 2026-01-16. Read it rendered on the official docs.

More in Assets

Assets
Citizen Characters
Clothing
Cloud Assets
Custom Assets
File System
First Time Setup
First-Person Weapons
← All documentation

Community wiki — not affiliated with Facepunch Studios. For the latest and most authoritative information, see the official developer wiki.