A fundamental numerical and scientific computing standard library for JavaScript and TypeScript, running in browsers and Node.js.
dustin/go-humanize
A small Go library of formatters that turn byte sizes, times, numbers and ordinals into human-friendly strings.
- Stars
- 4,846
- Forks
- 278
- Open issues
- 27
- Last commit
- 11 days ago
What is it?
go-humanize is a Go package that converts raw values such as byte counts, timestamps, and integers into strings people can read quickly. Byte sizes like 82854982 become "83 MB" or "79 MiB", and times can be expressed relative to now, such as "7 hours ago" or "3 days from now".
The library also covers ordinals (1st, 2nd, 193rd), comma-separated thousands, trimmed float formatting, and SI prefixes such as nM. A subpackage named english adds simple pluralization and word-list joining, including Oxford-comma lists.
The functions are plain Go calls with no extra dependencies described in the project, and the API is documented on pkg.go.dev.
Key features
- 01Formats byte sizes in SI (MB) or binary (MiB) units.
- 02Renders times as relative phrases like "12 seconds ago".
- 03Adds ordinal suffixes such as 1st, 2nd, 3rd.
- 04Inserts thousands separators into integers.
- 05Provides English pluralization and word-series joining in the english subpackage.
Use cases
- Showing file sizes in a CLI or web dashboard.
- Displaying "last updated 5 minutes ago" style timestamps in a UI.
- Formatting counts and money amounts in reports.
- Generating grammatically correct English labels for dynamic messages.
Quick start
- 1
Install the library with go get
go get github.com/dustin/go-humanize - 2
Import it in your Go code as humanize
Things to know
- The license could not be determined from the project metadata, so check the repository before using it commercially.
Topics
FAQ
- What is go-humanize?
- A small Go library of formatters that turn byte sizes, times, numbers and ordinals into human-friendly strings. go-humanize is a Go package that converts raw values such as byte counts, timestamps, and integers into strings people can read quickly. Byte sizes like 82854982 become "83 MB" or "79 MiB", and times can be expressed relative to now, such as "7 hours ago" or "3 days from now".
- Is go-humanize free to use? What license does it have?
- go-humanize is open source under the Other license. Check the license terms before using it in commercial products.
- Is go-humanize still maintained?
- Actively maintained. The last commit to go-humanize was on Oct 13, 2026.
- What can I use go-humanize for?
- Showing file sizes in a CLI or web dashboard. Displaying "last updated 5 minutes ago" style timestamps in a UI. Formatting counts and money amounts in reports. Generating grammatically correct English labels for dynamic messages.
- How do I install go-humanize?
- Install the library with go get: go get github.com/dustin/go-humanize Import it in your Go code as humanize
- Where can I get go-humanize?
- The source code and installation instructions are on GitHub: https://github.com/dustin/go-humanize
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A C++ formatting library offering a fast, type-safe alternative to C stdio and iostreams, implementing C++20 std::format.
A desktop Swiss Army knife for developers, bundling about 30 small tools for encoding, formatting, converting, testing and generating data.
A pure-Python utility library of 230+ extra constructs that extend the standard library, with no dependencies.
Google's core Java libraries, adding collections like multimap and multiset, graph structures, and utilities for concurrency, I/O, hashing and strings.
A command-line tool and library for transferring data to or from servers using URLs, covering HTTP, FTP, SFTP, SMTP and many other protocols.