How to Convert Go to TOML - Step by Step Guide

Step 1

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.

•
Paste a Go struct literal: Copy an initialized struct with its configuration values
•
Upload a file: Load Go code from a .go or .txt file on your computer
•
Quick samples: Try a preset struct (basic config, database, nested structure)

Example: Go Database Config

A typical Go struct for database configuration:

Database{
    Host: "localhost",
    Port: 5432,
    Username: "dbuser",
    Password: "secret123",
    MaxConnections: 100
}
Step 2

Convert to TOML

Click Convert and the editor's contents are sent to our server, which returns readable TOML configuration:

•
Sections preserved: Nested structs become [Section] and [Section.Sub] tables
•
Arrays preserved: Go slices come out as TOML array syntax
•
Numbers kept as-is: Long IDs, leading zeros and decimals are shown exactly as returned

Example: Generated TOML Output

The database config above becomes this TOML:

Host = "localhost"
Port = 5432
Username = "dbuser"
Password = "secret123"
MaxConnections = 100
Step 3

Export Your TOML Configuration

Use the result in Cargo.toml, Hugo, application configs, or any TOML-based tool:

•
Copy to clipboard: One click to paste the TOML into your config files
•
Download as .toml: Save the result as a TOML configuration file
•
Standard TOML: Works with Rust Cargo, Hugo, and any TOML parser

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.