JSON to Go Structs Converter
Convert raw JSON payloads into idiomatic Go structs with aligned tags, standard initialisms (ID, URL, API), and time.Time detection.
100% Zero-Egress Sandbox
Never upload sensitive enterprise JSON or production API responses to third-party servers. All type inference occurs strictly inside your browser.
Idiomatic Go Initialisms
Conforms to Effective Go conventions. Automatically formats acronyms as uppercase (UserID, APIURL, UUID) and exports fields with PascalCase.
Multi-Tag & time.Time Support
Automatically imports "time" for ISO date strings, aligns columns, and lets you toggle json:, yaml:, and db: tags.
JSON to Go Structs: Type System Mapping
How Nazamos converts dynamic JSON primitives into Go's statically typed structures:
| JSON Data Type | Inferred Go Type | Go Struct Tag & Behavior |
|---|---|---|
| String ("hello") | string | `json:"fieldName"` |
| Integer (42, -100) | int64 | 64-bit integer prevents overflow on database primary keys & epoch timestamps |
| Float (19.99, 3.14) | float64 | Standard IEEE-754 double precision floating point |
| Boolean (true / false) | bool | Standard Go boolean |
| ISO-8601 Date ("2026-09-20T...") | time.Time | Requires `import "time"` (automatically unmarshaled by encoding/json) |
| Null / Optional Field | *T or any | `json:"fieldName,omitempty"` (pointer allows discriminating nil from zero-values) |
| Homogeneous Array ([1, 2, 3]) | []int64 / []string | Go slice of the inferred element type |
| Object Array ([{…}, {…}]) | []ItemStruct | Schemas merged across all array items into a unified struct definition |
| Nested Object ({"user": {…}}) | User | Separated into dedicated named top-level struct with PascalCase |
1. Standard Library Unmarshaling (`encoding/json`)
How to parse JSON payloads into your generated structs using Go's standard library:
package main
import (
"encoding/json"
"fmt"
"log"
"time"
)
// Generated Struct from Nazamos
type UserResponse struct {
UserID int64 `json:"userId"`
UserName string `json:"userName"`
UserEmail string `json:"userEmail"`
IsActive bool `json:"isActive"`
CreatedAt time.Time `json:"createdAt"`
}
func main() {
rawJSON := []byte(`{
"userId": 1042,
"userName": "alex_developer",
"userEmail": "alex@example.com",
"isActive": true,
"createdAt": "2026-09-20T10:30:00Z"
}`)
var user UserResponse
if err := json.Unmarshal(rawJSON, &user); err != nil {
log.Fatalf("Failed to unmarshal JSON: %v", err)
}
fmt.Printf("Parsed User ID: %d, Name: %s\n", user.UserID, user.UserName)
}2. HTTP API Request Binding (net/http & Gin)
Stream JSON directly from an HTTP request body into your struct:
// net/http standard library handler
func HandleCreateUser(w http.ResponseWriter, r *http.Request) {
var payload UserResponse
if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {
http.Error(w, "Invalid JSON payload", http.StatusBadRequest)
return
}
defer r.Body.Close()
// Process payload...
w.WriteHeader(http.StatusCreated)
}