How to Edit XNB Files for Stardew Valley, Terraria and Other Games
XNB files are compressed files that store data, images, and maps for various games such as Stardew Valley and Terraria. They have the .xnb file extension and are located inside the game's Content folder. For example, Abigail's portrait shown during dialogue in Stardew Valley is from Content\\\\Portraits\\\\Abigail.xnb.
If you want to modify the game's content, you need to edit the XNB files. However, you can't edit them directly. You need to unpack them first, which means extracting the inner file that contains the actual data or image. Then you can edit the inner file using a text editor or an image editor. After that, you need to pack the file back into an .xnb format and replace the original file in the game folder.
In this article, we will show you how to edit XNB files using two tools: StardewXnbHack and xnbcli. We will also give you some tips on how to make changes to the game's data, images, and maps.
StardewXnbHack is an open-source and cross-platform tool for unpacking XNB files. It can't pack files back into .xnb, but you rarely need to do that. You can use this tool for Stardew Valley and other games that use XNA Framework.
To use StardewXnbHack, follow these steps:
Install SMAPI, which is a modding API for Stardew Valley.
Download StardewXnbHack from here. Make sure you download the file for your operating system, such as StardewXnbHack-*-for-windows.zip, not the source code!
Unzip the download into your game folder, so StardewXnbHack.exe is in the same folder as StardewValley.exe.
Double-click StardewXnbHack.exe (on Windows), StardewXnbHack.sh (on Linux), or StardewXnbHack.command (on MacOS) to unpack your game's entire Content folder.
That's it! It'll unpack the files into a Content (unpacked) folder. The unpacked files will already be compatible with Content Patcher, which is a mod that lets you change the game's content without replacing the actual game files.
xnbcli is another open-source and cross-platform tool for packing and unpacking XNB files. This supports XNB files for other games too, but it can't handle some files specific to Stardew Valley. StardewXnbHack is recommended instead.
To use xnbcli, follow these steps:
Download xnbcli from here. Make sure you download the file for your operating system, such as xnbcli-*-for-windows.zip, not the source code!
Unzip the download into a folder of your choice.
Find the XNB file you want to unpack and copy it into xnbcli's packed folder.
Double-click unpack.bat (Windows), unpack.sh (Linux), or unpack.command (Mac) to unpack the file.
The unpacked file will be in xnbcli's unpacked folder.
If you want to repack the file after editing it, copy it back into xnbcli's unpacked folder.
Double-click pack.bat (Windows), pack.sh (Linux), or pack.command (Mac) to pack the file.
The packed file will be in xnbcli's packed folder.
Move the packed file back to the original location in the game folder.
Each XNB file has its own format depending on what type of content it stores. There are three main types of XNB files: data, images, and maps.
Data XNB files store information such as item properties, NPC schedules, dialogue lines, etc. They usually have a aa16f39245