go-humanize

Formats byte sizes, durations, big numbers, and ordinals into human-friendly strings for Go programs.

Library
Go
vv1.1.0
4,833 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
71 /100 Good
Development Activity 80
Maintenance 44
Community 60
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
77 /100 Good
Architecture 78
Code Quality 80
Innovation 85
Learning Curve 65

go-humanize is a small, dependency-free Go library that turns raw numeric and time values into the kind of strings people actually want to read — “83 MB” instead of 82854982, “3 weeks ago” instead of a raw timestamp, “1,234,567” instead of an unformatted integer. It groups its functions by concern: byte-size formatting (SI and IEC units, plus parsing back from a string), relative time formatting with a customizable magnitude table, comma-grouped integers and floats (including arbitrary-precision big.Int/big.Float support), ordinal suffixes, SI-prefix notation, and a small english subpackage for basic English pluralization and word-series joining.

The project has been stable for over a decade and is one of the most widely vendored Go utility packages in the ecosystem, used by tools like Docker, Kubernetes, and Terraform for exactly the kind of human-facing number and time formatting that the Go standard library deliberately leaves out.

What You Get

  • SI and IEC byte-size formatting (Bytes, IBytes, and digit-limited BytesN/IBytesN variants) plus ParseBytes to go back from a string like “42 MB” to a uint64
  • Relative time formatting (Time, RelTime, CustomRelTime) with a fully overridable magnitude/format table for custom thresholds and wording
  • Comma-grouped number formatting for int64, float64, and arbitrary-precision big.Int/big.Float values
  • Ordinal suffix formatting (Ordinal(193) -> “193rd”) and SI-prefix formatting/parsing (SI, ComputeSI, ParseSI) across the full quecto-to-quetta prefix range
  • A humanize/english subpackage for regular-and-common-irregular English pluralization and comma/conjunction word-series joining

Common Use Cases

  • Showing upload/download sizes, disk usage, or file sizes in CLI tools and dashboards
  • Rendering “created 3 days ago” / “updated 2 hours ago” style timestamps in web UIs and API responses
  • Formatting large counts (bytes transferred, row counts, currency-like figures) with thousands separators in logs or reports
  • Building CLI or API output that pluralizes counts correctly (“1 object” vs “42 objects”) without hand-rolled pluralization logic

Under The Hood

Architecture

go-humanize is organized as a single flat humanize package with one function-per-concern file (bytes.go, times.go, comma.go, si.go, ordinals.go, number.go, big.go, ftoa.go) plus a separate humanize/english subpackage for pluralization and word-series joining, which itself imports the root package for its Comma helper. There is no internal layering, dependency injection, or shared mutable state beyond a few package-level lookup tables and a compiled regex built once in an init() for SI parsing — each formatter is an independent, side-effect-free function, which keeps the blast radius of any single change narrow but also means the package offers no extensibility beyond the RelTimeMagnitude table exposed for CustomRelTime.

Tech Stack

The module (go.mod, go 1.16) has zero external dependencies — every function is built from the Go standard library alone (fmt, math, math/big, strconv, strings, unicode, time, sort, regexp, errors, bytes). CI runs on GitHub Actions, building with go build ./... and testing with go test ./... against a pinned Go toolchain version. There is no build step beyond the standard Go toolchain and no runtime deployment target, since it’s a library rather than a service.

Code Quality

Every source file has a matching _test.go counterpart, including a dedicated fuzz test for comma formatting (comma_fuzz_test.go), and CI runs the full suite with go test -v ./... on every push and pull request. Error handling is explicit where inputs can be malformed — ParseBytes and ParseSI return a Go error rather than panicking — though FormatFloat panics on malformed format-directive strings, which is a sharp edge for callers passing user-supplied format strings. Naming follows idiomatic Go conventions (exported PascalCase functions with runnable-example doc comments), and no dedicated linter configuration is present, though the small, single-purpose functions leave little surface for style drift.

API Design The library is deliberately zero-configuration: importing humanize and calling a single function like humanize.Bytes(n) or humanize.Time(t) is the entire integration, with every exported function documented via a doc comment that includes a literal input/output example. The english subpackage is kept separate rather than folded into the root package, avoiding namespace bloat for functionality most callers won’t need. The one API wrinkle is FormatFloat’s custom "#,###.##"-style format-string syntax, which is more expressive but less discoverable than the rest of the package’s plain function calls.

Used by 19 apps in this directory

Go
97%
Apache 2.0

infracost

Developer Tools · Devops

12,560

Infracost shows cloud cost estimates for Terraform, CloudFormation, and AWS CDK before you deploy — in your terminal, editor, AI coding agent, and pull requests.

View details
82
Repo Health
78
Technical
67
Dependency
Built with
Go 97%
Updated 2 weeks ago
Go
99%
AGPL 3.0

MinIO

File Storage

61,332

High-performance, S3-compatible object storage built for AI/ML and analytics workloads — run it anywhere from a laptop to a petabyte-scale cluster.

View details
59
Repo Health
85
Technical
65
Dependency
Built with
Go 99%
Updated 6 months ago
Go
82%
GPL 3.0

Navidrome

File Storage · Music Audio

24,068

Run your own personal Spotify — stream your entire music collection from any device, anywhere, forever.

View details
91
Repo Health
81
Technical
69
Dependency
Built with
Go 82%
JavaScript 15%
Updated 2 weeks ago
Go
69%
Apache 2.0

OSV.dev

Security

2,966

Google's open-source vulnerability database that maps CVEs to exact package versions across 50+ ecosystems with a public API and data dumps.

View details
87
Repo Health
82
Technical
66
Dependency
Built with
Go 69%
Python 21%
Updated 2 weeks ago
Go
90%
AGPL 3.0

Pyroscope

Developer Tools · Devops · Monitoring

11,697

An open-source, horizontally scalable continuous profiling platform that pinpoints CPU, memory, and I/O bottlenecks down to the exact line of code, built by Grafana Labs alongside Loki, Tempo, and Mimir.

View details
92
Repo Health
89
Technical
65
Dependency
Built with
Go 90%
Updated 2 weeks ago
TypeScript
50%
Other

SigNoz

Analytics · Monitoring

32,323

Self-host your entire observability stack — logs, metrics, traces, and LLM monitoring — in one OpenTelemetry-native platform, without the Datadog bill.

View details
92
Repo Health
83
Technical
67
Dependency
Built with
TypeScript 50%
Go 38%
Updated 2 weeks ago
Go
100%
Apache 2.0

SpiceDB

Authentication · Databases · Security

7,132

An open source, Google Zanzibar-inspired authorization database that models permissions as relationships and evaluates fine-grained access checks at massive scale with single-digit millisecond latency.

View details
89
Repo Health
89
Technical
67
Dependency
Built with
Go 100%
Updated 2 weeks ago
Go
75%
AGPL 3.0

Teleport

Authentication · Security

20,974

Zero-trust infrastructure access platform that replaces credentials and VPNs with short-lived certificates, SSO, and identity-aware proxies for SSH, Kubernetes, databases, RDP, and AI agents.

View details
92
Repo Health
81
Technical
68
Dependency
Built with
Go 75%
TypeScript 16%
Updated 1 months ago
Go
97%
BSD 3

Weaviate

Databases · Search

16,877

Open-source vector database combining semantic search, hybrid queries, RAG, and image search in a single cloud-native system built for production scale.

View details
91
Repo Health
85
Technical
68
Dependency
Built with
Go 97%
Updated 2 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers