Struct Packing Visualizer and Optimizer
Free to download on every platform. Comes pre-installed on BotFone, BotPad and BotFlip — with extra free apps included.
About this app
WHAT IT DOES
Struct Packing Visualizer and Optimizer is a developer-focused tool that visualizes Solidity struct storage packing and provides optimization recommendations. It takes contract source code from the user, parses struct definitions, and analyzes how struct fields are packed into 32-byte storage slots. The tool calculates the size of each field, identifies dynamic types, and determines the total storage slots used. It then generates a visual slot diagram showing how fields are arranged across storage slots, with color-coded blocks representing different field types and padding gaps. The tool also calculates packing efficiency and provides actionable recommendations for reordering fields to reduce storage usage and gas costs. This enables developers to optimize their contract's storage layout, reduce gas costs, and improve overall contract efficiency.
HOW TO USE
Paste your Solidity contract source code into the input area. Optionally, enter a specific struct name to focus on (leave empty to analyze all structs). Click "Visualize" to analyze the struct packing. The tool will display a summary showing the number of structs found and analyzed. Each struct is displayed with its name, total size in bytes, number of storage slots used, packing efficiency percentage, and a quality indicator (Efficient, Average, Poor). The slot visualization shows each storage slot with color-coded field blocks and padding gaps. Fields are displayed with their type, name, and size. If the packing quality is not efficient, the tool provides specific recommendations for reordering fields.
TECHNICAL NOTE: STORAGE SLOT PACKING ANALYSIS
The tool analyzes Solidity structs by parsing the source code to extract struct definitions and field types. For each field, it determines the storage size based on the Solidity type system: uint256 uses 32 bytes, uint128 uses 16 bytes, address uses 20 bytes, bool uses 1 byte, etc. Dynamic types (arrays, strings) always occupy a full 32-byte slot. The tool then simulates the packing algorithm used by the Solidity compiler, placing fields into 32-byte slots sequentially. If a field does not fit in the current slot, it is placed in the next slot and the remaining space is marked as padding. The tool calculates the total storage used, the number of slots, and the packing efficiency. Recommendations are generated based on the packing quality.
WHAT IT CANNOT SEE
The tool cannot automatically optimize structs without user input; it only provides recommendations. It is limited to the accuracy of the source code analysis; syntax variations may cause parsing issues. It cannot detect structs in external contracts or libraries that are imported into the contract. It is limited by the parser's ability to handle Solidity syntax variations, including newer language features. It cannot visualize struct packing for non-EVM chains.
PLEASE NOTE
This tool is designed exclusively for Solidity contracts on EVM-compatible chains. It does not support other smart contract languages. The analysis is based on static source code analysis and may not reflect the exact storage layout if the contract uses complex inheritance or custom storage patterns. The recommendations are guidance and should be validated with actual gas measurements. The tool is read-only and does not modify any state. The tool provides no warranty that the analysis is complete or accurate; users are responsible for verifying the results.