go-humanize

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

Library
Go
vv1.0.1
4,811stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
41/100Fair
Development Activity4
Maintenance0
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture78
Code Quality80
Innovation85
Learning Curve65

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 18 apps in this directory

Go
85%
Apache 2.0

Argo Workflows

Devops · Data Engineering

16,943

The most popular Kubernetes-native workflow engine for orchestrating containerized DAGs, ML pipelines, CI/CD, and parallel batch jobs at scale.

View details
95
Repo Health
90
Technical
68
Dependency
Built with
Go85%
TypeScript11%
Updated yesterday
Go
98%
Apache 2.0

Caddy

Devops · Security

75,334

The only web server that obtains and renews TLS certificates automatically, with HTTP/1-2-3 support and zero dependency on external runtimes.

View details
92
Repo Health
86
Technical
76
Dependency
Built with
Go98%
Updated 2 days ago
Go
75%
AGPL 3.0

Coder

Devops · Developer Tools · Code Editors

14,299

Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.

View details
93
Repo Health
90
Technical
69
Dependency
Built with
Go75%
TypeScript23%
Updated today
Go
63%
Apache 2.0

Coroot

Analytics · Monitoring

7,895

eBPF-powered observability with AI root cause analysis — zero code changes required, full-stack visibility out of the box.

View details
88
Repo Health
80
Technical
65
Dependency
Built with
Go63%
Vue35%
Updated 3 days ago
Go
92%
AGPL 3.0

Cozy Stack

File Storage · Productivity

1,270

Self-hosted personal cloud platform that unifies your files, apps, and devices in one private space you fully control.

View details
94
Repo Health
77
Technical
67
Dependency
Built with
Go92%
Updated 2 days ago
Go
98%
Other

Crush

Developer Tools · AI Code Assistants · AI Assistants

27,798

Your terminal coding companion — wire up any LLM with LSP intelligence, MCP extensibility, and a skills system that learns your workflow.

View details
87
Repo Health
86
Technical
69
Dependency
Built with
Go98%
Updated today
Go
79%
Apache 2.0

Dolt

Databases · Data Engineering · Developer Tools

24,298

The SQL database you can branch, merge, diff, and clone — Git for your data, MySQL-compatible and ready for multi-agent AI workflows.

View details
90
Repo Health
9
Technical
67
Dependency
Built with
Go79%
Shell20%
Updated 2 days ago
Go
83%
MIT

Gitea

Devops · Developer Tools · Project Management

57,677

Self-hosted DevOps in a single Go binary — Git hosting, GitHub Actions-compatible CI/CD, and 30+ package registries without any SaaS dependency.

View details
93
Repo Health
79
Technical
66
Dependency
Built with
Go83%
Updated today
Go
61%
Apache 2.0

Harness Open Source

Developer Tools · Devops · Code Editors

38,169

A unified open source DevOps platform combining Git hosting, CI/CD pipelines, cloud development environments, and artifact registries in a single self-hosted system.

View details
89
Repo Health
79
Technical
64
Dependency
Built with
Go61%
TypeScript34%
Updated 2 days 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

Search