BurntSushi/toml has 5,029 GitHub stars and 569 forks. GitHot measured +1 stars in 24 hours. Last checked 2026-11-06 16:23 UTC. Last push 2026-08-18.
TOML parser for Golang with reflection.
Measured star growth
- in 24h
- +1
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalTOML stands for Tom's Obvious, Minimal Language. This Go package provides a
reflection interface similar to Go's standard library json and xml packages.
Compatible with TOML version v1.1.0.
Documentation: https://pkg.go.dev/github.com/BurntSushi/toml
See the releases page for a
changelog; this information is also in the git tag annotations (e.g. git show v0.4.0).
This library requires Go 1.19 or newer; add it to your go.mod with:
% go get github.com/BurntSushi/toml@latest
It also comes with a TOML validator CLI tool:
% go install github.com/BurntSushi/toml/cmd/tomlv@latest
% tomlv some-toml-file.toml
Examples
For the simplest example, consider some TOML file as just a list of keys and values:
Age = 25
Cats = [ "Cauchy", "Plato" ]
Pi = 3.14
Perfection = [ 6, 28, 496, 8128 ]
DOB = 1987-07-05T05:45:00Z
Which can be decoded with:
type Config struct {
Age int
Cats []string
Pi float64
Perfection []int
DOB time.Time
}
var conf Config
_, err := toml.Decode(tomlData, &conf)
You can also use struct tags if your struct field name doesn't map to a TOML key value directly:
some_key_NAME = "wat"
type TOML struct {
ObscureKey string `toml:"some_key_NAME"`
}
Beware that like other decoders only exported fields are considered when encoding and decoding; private fields are silently ignored.
Using the Marshaler and encoding.TextUnmarshaler interfaces
Here's an example that automatically parses values in a mail.Address:
contacts = [
"Donald Duck <[email protected]>",
"Scrooge McDuck <[email protected]>",
]
Can be decoded with:
// Create address type which satisfies the encoding.TextUnmarshaler interface.
type address struct {
*mail.Address
}
func (a *address) UnmarshalText(text []byte) error {
var err error
a.Address, err = mail.ParseAddress(string(text))
return err
}
// Decode it.
func decode() {
blob := `
contacts = [
"Donald Duck <[email protected]>",
"Scrooge McDuck <[email protected]>",
]
`
var contacts struct {
Contacts []address
}
_, err := toml.Decode(blob, &contacts)
if err != nil {
log.Fatal(err)
}
for _, c := range contacts.Contacts {
fmt.Printf("%#v\n", c.Address)
}
// Output:
// &mail.Address{Name:"Donald Duck", Address:"[email protected]"}
// &mail.Address{Name:"Scrooge McDuck", Address:"[email protected]"}
}
To target TOML specifically you can implement the UnmarshalTOML interface in
a similar way.
More complex usage
See the _example/ directory for a more complex example.
Explore related projects
codecrafters-io/build-your-own-x
Master programming by recreating your favorite technologies from scratch.
560,411 starspublic-apis/public-apis
A collective list of free APIs
496,745 starsmorluto/rea
Reverse engineer anything with agents, from app behavior down to native binaries.
437,863 starsopenclaw/openclaw
The AI that really does things. Any OS. Any Platform. The lobster way. 🦞
394,063 stars