https://github.com/buarki/viztruct
Struct padding visualizer
https://github.com/buarki/viztruct
go lowlevel webassembly
Last synced: 2 months ago
JSON representation
Struct padding visualizer
- Host: GitHub
- URL: https://github.com/buarki/viztruct
- Owner: buarki
- Created: 2025-04-16T01:12:57.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-07T01:23:53.000Z (about 1 year ago)
- Last Synced: 2026-01-14T23:40:21.646Z (5 months ago)
- Topics: go, lowlevel, webassembly
- Language: Go
- Homepage: https://viztruct.vercel.app
- Size: 21.4 MB
- Stars: 37
- Watchers: 1
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
 [](https://viztruct.vercel.app/) [](https://github.com/buarki/viztruct/actions/workflows/release.yml)
# viztruct
## Table of Contents
- [CLI installation](#cli-installation)
- [Usage](#usage)
- [Minimalist webapp](#website)
- [CI/CD plugin](./cmd/ci-plugin/README.md)

SVG visualization:

## CLI installation
### Go install
```sh
go install github.com/buarki/viztruct/cmd/viztruct@latest
```
### Download binaries
```sh
ARCH="arm64" # or amd64
OS="darwin" # or linux
# get latest tag using GitHub API
VERSION=$(curl -s "https://api.github.com/repos/buarki/viztruct/releases/latest" | jq -r .tag_name)
# download binary
BINARY_URL="https://github.com/buarki/viztruct/releases/download/$VERSION/viztruct-$OS-$ARCH"
curl -L "$BINARY_URL" -o viztruct
# install
chmod +x viztruct
sudo mv viztruct /usr/local/bin/
# verify
viztruct --version
```
### Build it locally
Build the CLI:
```sh
git clone git@github.com:buarki/viztruct.git
cd viztruct
make build-cli
sudo mv viztruct /usr/local/bin/
```
## Usage:
### Analyze structs from a path
```sh
viztruct --path ./internal/samples/dumb_service.go --format=txt
```
### Get JSON output
```sh
viztruct --path ./internal/samples/dumb_service.go --format=json
```
### Generate SVG visualization
```sh
viztruct --path ./internal/samples/dumb_service.go --format=json --svg
```
### Analyze and define the optimization strategy
```sh
viztruct --path ./internal/samples/dumb_service.go --format=txt --strategies=alignment,size,group,greedy
```
### Show help
```sh
viztruct --help
```
The tool will print the struct layout analysis to stdout. Use the `--svg` flag to generate an SVG visualization.
## Minimalist webapp
If you want to use a limited version of viztruct (since it supports only explicitly defined types) in your browser just visit the [deployed webapp](https://viztruct.vercel.app). You can paste/type your struct in the text input area and get a full padding analysis.