How to Convert Go to TOML - Step by Step Guide
Input Your Go Struct Literal
Paste your Go struct literal with configuration data. TOML suits application configs, especially Rust projects (Cargo.toml), Hugo sites, and tools built on BurntSushi/toml.
Example: Go Database Config
A typical Go struct for database configuration:
Database{
Host: "localhost",
Port: 5432,
Username: "dbuser",
Password: "secret123",
MaxConnections: 100
}Convert to TOML
Click Convert and the editor's contents are sent to our server, which returns readable TOML configuration:
Example: Generated TOML Output
The database config above becomes this TOML:
Host = "localhost" Port = 5432 Username = "dbuser" Password = "secret123" MaxConnections = 100
Export Your TOML Configuration
Use the result in Cargo.toml, Hugo, application configs, or any TOML-based tool:
Frequently Asked Questions
What Go input does this expect?
A Go struct literal with your configuration values, for example Config{Title: "App", Port: 8080}. Field names become TOML keys, nested structs become TOML sections, and slices become TOML arrays.
Is my Go code sent to a server?
Yes. When you click Convert, the code in the editor is sent to our server, which builds the TOML and sends it back. Nothing is sent while you type, paste or upload, and nothing is kept — a reload starts with an empty editor. Leave passwords, API keys and other secrets out of the code you convert.
Are long numbers kept exactly?
Yes. The TOML comes back as plain text and is shown exactly as received, so long IDs like 8901240544102066246, codes like "00501" and numbers like 14.50 are never rounded or reformatted. Need to read a TOML file instead? Open it with TOML to JSON.
How are nested structs and slices handled?
A nested struct becomes a TOML section: a Server struct with a Database field turns into [Server] and [Server.Database] tables. A Go slice such as []string{"a", "b"} becomes a TOML array ["a", "b"].
Can I use the output in Cargo.toml or Hugo?
The result is standard TOML, so it drops into any TOML-based config: Cargo.toml, Hugo, or your own application settings. Check that the key names match what your tool expects before you ship it.
Is it free?
Yes, and there is no sign-up. Every conversion goes through our server, so when a lot of requests arrive at once you may be asked to wait a minute and try again. Going the other way? JSON to TOML turns a JSON object into TOML.
Related Tools
Go to JSON
Convert Go structs and data structures to JSON format
Go to YAML
Convert Go structs to YAML configuration format
Go to XML
Convert Go structs to XML format
Go to CSV
Export Go data to CSV for spreadsheets and data analysis
Go to SQL
Generate SQL CREATE TABLE and INSERT statements from Go structs
Go to Protobuf
Generate Protocol Buffers schema from Go structs for gRPC