Compare Go JSON Online
Paste two Go JSON objects (from json.Marshal or API responses). See what was added, removed, or changed — key by key.
🔒 100% private — runs entirely in your browseror try sample data
Paste two Go JSON objects (from json.Marshal or API responses). See what was added, removed, or changed — key by key.
🔒 100% private — runs entirely in your browseror try sample data
Go JSON Diff compares two JSON objects — typically the output of json.Marshal() from Go structs or maps — and shows you exactly which keys were added, removed, or modified. Go's encoding/json package handles serialization via struct tags, but provides no built-in diff capability.
Go developers frequently work with JSON for Kubernetes manifests, Docker configs, REST APIs, and gRPC gateway responses. While reflect.DeepEqual() checks equality of Go values, it returns only a boolean. Libraries like go-cmp provide detailed diffs, but this tool gives you the same visual insight instantly — no go get required.
Paste your JSON (e.g., K8s deployment specs, Docker Compose configs, or API response bodies). The tool handles nested objects, arrays, nulls, and mixed types. Everything runs client-side — your data never leaves your machine.
package main import ( "encoding/json" "fmt" "reflect"
) type Config struct { Host string `json:"host"` Port int `json:"port"` Debug bool `json:"debug"`
} func main() { json1 := `{"host": "localhost", "port": 8080, "debug": true}` json2 := `{"host": "0.0.0.0", "port": 8080, "debug": false}` var c1, c2 Config json.Unmarshal([]byte(json1), &c1) json.Unmarshal([]byte(json2), &c2) fmt.Println(reflect.DeepEqual(c1, c2)) // false — but which field?
}reflect.DeepEqual tells you if values differ but not which fields changed. Use this tool for a detailed breakdown.
package main import ( "encoding/json" "fmt"
) func diffMaps(a, b map[string]interface{}, path string) { for key := range a { p := path + "." + key if _, ok := b[key]; !ok { fmt.Printf("REMOVED %s: %v\n", p, a[key]) } else if !reflect.DeepEqual(a[key], b[key]) { fmt.Printf("CHANGED %s: %v -> %v\n", p, a[key], b[key]) } } for key := range b { if _, ok := a[key]; !ok { fmt.Printf("ADDED %s.%s: %v\n", path, key, b[key]) } }
} func main() { var m1, m2 map[string]interface{} json.Unmarshal([]byte(`{"a": 1, "b": 2}`), &m1) json.Unmarshal([]byte(`{"a": 1, "c": 3}`), &m2) diffMaps(m1, m2, "root")
}Map-based diff works for flat structures. Nested objects need recursive handling with type assertions.
package main import ( "encoding/json" "fmt" "github.com/google/go-cmp/cmp"
) func main() { var obj1, obj2 map[string]interface{} json.Unmarshal([]byte(`{"name": "svc", "replicas": 2}`), &obj1) json.Unmarshal([]byte(`{"name": "svc", "replicas": 3, "port": 8080}`), &obj2) diff := cmp.Diff(obj1, obj2) fmt.Println(diff) // - "replicas": float64(2), // + "replicas": float64(3), // + "port": float64(8080),
}go-cmp gives detailed diffs similar to this tool. Note: JSON numbers unmarshal as float64 by default.
Go struct fields starting with a lowercase letter are unexported and ignored by json.Marshal(). If two structs differ only in unexported fields, their JSON output will be identical. Always use exported fields (uppercase) with json:"tag" for data you need to compare.
By default, json.Unmarshal() converts all JSON numbers to float64. This means 1 becomes 1.0, and large integers lose precision. Use json.Decoder with UseNumber() to preserve numbers as json.Number strings — but then equality checks require type awareness.
The json:"field,omitempty" tag omits fields with zero values (0, "", false, nil) from JSON output. This means two structs with different zero-value fields may produce identical JSON. Be aware that omitted fields won't appear in diffs.
Paste your JSON objects into the two panels and click Compare. The tool highlights added, removed, and modified keys with color-coded diffs.
Yes. The tool performs deep comparison of nested objects, arrays, and mixed structures at any depth. Nested changes are shown with path-based highlighting.
reflect.DeepEqual compares Go values, not JSON. When you unmarshal into interface{}, all numbers become float64, which may not match your struct's int fields. Unmarshal into the same concrete type for reliable comparison.
Yes. This tool runs entirely in your browser using client-side JavaScript. Your data is never sent to any server, making it safe for comparing Kubernetes configs or API responses.
Yes. Paste two K8s manifests in JSON format and the tool will show exactly which fields changed. For YAML manifests, convert to JSON first (many online converters are available).
The tool compares JSON output as-is. Fields with omitempty that are zero-valued won't appear in the JSON, so they'll show as removed or added depending on which side has them.