I Help You

Go Struct Tag Generator

Add json, yaml, db, xml, form, and bson struct tags to any Go struct — PascalCase fields auto-converted to snake_case tag values. Replaces or adds tags instantly. Free, and it runs entirely in your browser — nothing you enter is uploaded.

How to use the Go Struct Tag Generator

1. Paste your Go struct definition (with or without existing tags) into the left panel.

2. Choose which tag types to generate — json, yaml, db, xml, form, or bson.

3. Tags are generated automatically: PascalCase field names are converted to snake_case tag values.

Tip: existing tags are replaced, so you can use this to update or add tags to existing structs.

What is it?

Go struct tags control how each field is serialised to JSON, YAML, databases (sqlx), XML, and MongoDB (bson). Writing them manually for every field is repetitive and inconsistent. This tool automates it — converting PascalCase Go field names to the correct snake_case tag values.

Tag format: `json:"field_name" yaml:"field_name" db:"field_name"`. Common conversions: FirstName → first_name, UserID → user_id, ProfileURL → profile_url. The tool handles multi-word acronyms correctly — CreatedAt → created_at, IsAdmin → is_admin.

Multiple tag types can be generated simultaneously, which is useful when a struct is used across different serialisation contexts — for example, a struct that is read from a database (db tag), returned as JSON (json tag), and stored in MongoDB (bson tag).

Example

Go Struct (no tags)
type User struct {
	FirstName string
	Email     string
}
↓
With Tags
type User struct {
	FirstName  string   `json:"first_name" db:"first_name"`
	Email      string   `json:"email" db:"email"`
}

PascalCase → snake_case: FirstName → first_name, UserID → user_id, ProfileURL → profile_url

Benefits

Generate accurate code from your actual data

TypeScript interfaces, Python dataclasses, and OpenAI function schemas are generated directly from your real JSON — accurate field names, correct types, no guesswork.

Control LLM API costs before you scale

Token counts and per-call cost estimates for GPT-4o, Claude 3.5, and Gemini let you optimise prompt size and model choice before a feature goes to production.

Ready-to-run code and configs, not boilerplate

Every tool produces output you can paste directly into your project — API request code, prompt templates, chunk configurations — adapt rather than write from scratch.

Purpose-built for AI engineering workflows

From RAG chunking strategy to prompt template selection to function calling schema design — tools built for the specific problems AI engineers encounter daily.

Frequently asked questions

Does this handle acronyms correctly?

Yes — PascalCase conversion accounts for consecutive uppercase letters. UserID → user_id, ProfileURL → profile_url, HTTPMethod → http_method. The conversion follows Go naming conventions.

Can I use bson tags for MongoDB?

Yes — select the bson tag option. bson:"field_name" tags are used by the official MongoDB Go driver (go.mongodb.org/mongo-driver).

What if I have a custom tag value I don't want overwritten?

All existing tags on each field are replaced. If you need to keep custom tags, run the generator first and then manually edit those specific fields.

What is the db tag used for?

The db tag is used by sqlx and other SQL libraries to map struct fields to database column names. Without it, sqlx uses lowercase field names by default.

How do I add omitempty to specific fields?

After generating, manually add ,omitempty to the fields you want: json:"field_name,omitempty". A future version may support per-field options.