🌾 FarmHeart

← Back to Blog

Inventory and Crafting Systems for Browser Games

InventoryCraftingGame Design · 11 min read

An inventory system seems simple until you build one. Suddenly you're dealing with stack limits, drag-and-drop, item rarity tiers, equipment slots, recipe discovery, and a save format that won't explode when you add new items in a patch. Here's how to build inventory and crafting systems that scale from a weekend prototype to a full farming simulation.

Data-Driven Item Definitions

Never hardcode item properties. Define all items in a single JSON file (or module) with entries like:

The inventory itself only stores { itemId: "wheat_seeds", quantity: 47 } — never duplicate the full item definition in each slot. Look up the definition by ID when you need display info.

Slot-Based Inventory Grid

The standard approach: a fixed-size array of slots, each holding an item ID and quantity (or null if empty). Grid sizes of 20–40 slots work well for most games. Provide a way to expand (buy more slots, unlock a backpack upgrade) for progression.

Design DecisionTradeoffs
Fixed grid (Minecraft-style)Familiar UI, spatial memory, but wastes space
Scrollable listInfinite items visible, but loses spatial feel
Category tabs + gridBest of both for games with many item types
Weight-based (no slots)Realistic, but harder to visualize

Drag and Drop

Drag-and-drop is the expected interaction for inventory management. For browser games, you have two approaches:

Key behaviors to implement:

The Crafting System

Crafting transforms input items into output items according to recipes. The data structure is straightforward:

Each recipe has: inputs (array of {itemId, quantity}), output ({itemId, quantity}), station (optional — which crafting table/furnace is required), and unlocked (whether the player has discovered this recipe).

Recipe Discovery

Three common approaches:

  1. All recipes visible — simplest. The player sees every recipe from the start. Grayed-out recipes show what materials they're missing. Works for casual games.
  2. Unlock by obtaining ingredients — when the player first picks up Iron Ore, all recipes containing Iron Ore become visible. Creates natural progression tied to exploration.
  3. Experimentation — the player places items in a crafting grid and discovers recipes by trying combinations. Rewarding but frustrating without hints. Best combined with a recipe book that records discoveries.

Crafting UI Patterns

The two dominant patterns:

Batch crafting: Always support "craft 1 / craft 5 / craft all" buttons. Nothing kills the flow of a farming game like clicking "craft" 47 times to turn wheat into flour.

Equipment and Loadout Slots

Separate your inventory grid from equipment slots. Equipment slots are named positions (head, body, tool, accessory) that accept only items matching their type. Equipping an item moves it from inventory to the equipment slot; unequipping moves it back. If inventory is full when unequipping, block the action and show a message.

For farming games, the "tool belt" (a row of slots for active tools/items) is the main equipment interface. The currently selected slot determines what the player does when they click on the world — water with the watering can, plant with seeds, harvest with the sickle.

Sorting and Filtering

As the player accumulates items, manual organization becomes tedious. Provide:

Save Format and Migration

Your inventory save format will change as you add items and features. Plan for it:

Farming Game Specifics

Farming games have unique inventory challenges:

A Full Inventory in the Browser

FarmHeart features a complete inventory, crafting, and equipment system — hundreds of items, all running in your browser.

Play FarmHeart Now