whatisgithub

What is go-humanize?

dustin/go-humanize — explained in plain English

Analysis updated 2026-06-26

4,785GoAudience · developerComplexity · 2/5Setup · easy

In one sentence

A Go library that converts raw numbers and timestamps into natural human-readable text, like turning 82854982 into '83 MB' or a timestamp into '3 days ago'.

Mindmap

mindmap
  root((go-humanize))
    Byte sizes
      SI units
      Binary units
    Time formatting
      Relative past
      Relative future
    Number tools
      Ordinals
      Comma separators
      Float cleanup
      SI notation
    English helpers
      Pluralization
      Word lists
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Display file sizes as '83 MB' or '79 MiB' instead of raw byte counts in a Go application.

USE CASE 2

Show relative timestamps like '12 seconds ago' or '3 days from now' in a user-facing interface.

USE CASE 3

Format large numbers with comma separators and ordinal suffixes for dashboards or reports.

USE CASE 4

Generate grammatically correct English phrases like '1 object' or '5 objects' from a count.

What is it built with?

Go

How does it compare?

dustin/go-humanizeolekukonko/tablewriternsf/termbox-go
Stars4,7854,7894,778
LanguageGoGoGo
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

So what is it?

go-humanize is a small Go library that formats numbers and times into text that reads naturally to a person rather than as raw digits. Programs frequently need to show data to users, and a raw number like 82854982 is harder to read than "83 MB". The library handles these conversions so you do not have to write the formatting logic yourself. The byte size formatter takes a number and returns a string in megabytes, gigabytes, or the appropriate unit, and you can choose between SI units (MB, GB) and binary units (MiB, GiB). The time formatter takes a point in time and returns a phrase like "12 seconds ago" or "3 days from now" relative to the current moment. These two are the most common uses. Beyond sizes and times, the library also handles several other formatting tasks. The ordinal formatter turns a number like 193 into "193rd" with the correct English suffix. The comma formatter inserts thousand separators so 1000000 becomes "1,000,000". A float formatter strips trailing zeros so 2.240000 becomes "2.24". An SI notation formatter expresses very small or very large numbers using metric prefixes like nano or mega. An English-specific subpackage adds two more tools. One handles simple pluralization, returning "object" or "objects" depending on the count, with support for irregular forms. The other formats a list of words into a natural comma-separated series with a conjunction, such as "foo, bar and baz" or the Oxford comma variant "foo, bar, and baz". The library is installed via the standard Go module system and is well documented on pkg.go.dev. It has no external dependencies beyond the Go standard library.

Copy-paste prompts

Prompt 1
Show me how to format a byte count as a human-readable string like '83 MB' using go-humanize in Go.
Prompt 2
How do I display a relative timestamp like '3 days ago' in my Go app using go-humanize?
Prompt 3
Give me an example using go-humanize to add comma separators to a large number and get an ordinal suffix.
Prompt 4
How do I use go-humanize's English subpackage to pluralize a word correctly based on a count?

Frequently asked questions

What is go-humanize?

A Go library that converts raw numbers and timestamps into natural human-readable text, like turning 82854982 into '83 MB' or a timestamp into '3 days ago'.

What language is go-humanize written in?

Mainly Go. The stack also includes Go.

How hard is go-humanize to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is go-humanize for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.