Skip to main content
Version: Next

Benchmark Results

Generated: 2026-03-24 01:46:01 UTC

If you're interested in diving deeper, check out our benchmark repository.

Library Notes

Feature Comparison

FeaturePedantigoPlaygroundOzzoHumaGodanticGodasse
Declarative constraints✅ tags✅ tags✅ rules✅ tags✅ methods❌ hand-written
JSON Schema generation
Default values
Unmarshal + validate
Validate existing struct❌*

*Godasse requires hand-written Validate() methods

Library Descriptions

  1. Pedantigo - Struct tag-based validation (validate:"required,email,min=5"). JSON Schema generation with caching.

  2. Playground (go-playground/validator) - Struct tag-based validation. Rich constraint library, no JSON Schema.

  3. Ozzo (ozzo-validation) - Rule builder API (validation.Field(&u.Name, validation.Required, validation.Length(2,100))). No struct tags.

  4. Huma - OpenAPI-focused. Validates map[string]any against schemas, not structs directly.

  5. Godantic - Method-based constraints (FieldName() FieldOptions[T]). JSON Schema, defaults, streaming partial JSON.

  6. Godasse - Deserializer with default: tag. All constraint validation requires hand-written Validate() methods.


JSONValidate

JSON bytes → struct + validate

StructPedantigoPlaygroundOzzoHumaGodanticGodasse
Simple3.39 µs (19 allocs)4.23 µs (16 allocs)unsupported3.48 µs (26 allocs)unsupported5.34 µs (46 allocs)
Complex9.69 µs (39 allocs)10.95 µs (33 allocs)unsupported10.27 µs (78 allocs)unsupported17.26 µs (153 allocs)

Marshal

Validate + JSON marshal

StructPedantigoPlaygroundOzzoHumaGodanticGodasse
Simple1.88 µs (11 allocs)2.74 µs (9 allocs)unsupportedunsupportedunsupportedunsupported

New

Validator creation overhead

StructPedantigoPlaygroundOzzoHumaGodanticGodasse
Simple12.15 µs (110 allocs)16.85 µs (187 allocs)unsupported30.52 µs (255 allocs)27.06 µs (305 allocs)6.68 µs (72 allocs)
Complex29.36 µs (270 allocs)unsupportedunsupported75.07 µs (515 allocs)7.48 µs (75 allocs)23.31 µs (243 allocs)

OpenAPI

OpenAPI-compatible schema generation

StructPedantigoPlaygroundOzzoHumaGodanticGodasse
Uncached24.32 µs (204 allocs)unsupportedunsupported31.02 µs (255 allocs)unsupportedunsupported
Cached18 ns (0 allocs)unsupportedunsupported638 ns (6 allocs)unsupportedunsupported

Schema

JSON Schema generation

StructPedantigoPlaygroundOzzoHumaGodanticGodasse
Uncached23.74 µs (202 allocs)unsupportedunsupported30.93 µs (255 allocs)unsupportedunsupported
Cached19 ns (0 allocs)unsupportedunsupported628 ns (6 allocs)unsupportedunsupported

Validate

Validate existing struct (no JSON parsing)

StructPedantigoPlaygroundOzzoHumaGodanticGodasse
Simple1.42 µs (10 allocs)2.18 µs (7 allocs)12.94 µs (43 allocs)unsupported6.00 µs (48 allocs)unsupported
Complex2.31 µs (15 allocs)3.56 µs (9 allocs)12.43 µs (139 allocs)unsupported13.82 µs (120 allocs)unsupported
Large1.59 µs (22 allocs)2.05 µs (3 allocs)47.67 µs (254 allocs)unsupported14.62 µs (126 allocs)unsupported

Summary

Validate_Simple (struct validation)

Libraryns/opallocsvs Pedantigo
Pedantigo1.42 µs10baseline
Playground2.18 µs71.53x slower
Ozzo12.94 µs439.09x slower
Huma---
Godantic6.00 µs484.21x slower
Godasse---

Validate_Complex (nested structs)

Libraryns/opallocsvs Pedantigo
Pedantigo2.31 µs15baseline
Playground3.56 µs91.54x slower
Ozzo12.43 µs1395.37x slower
Huma---
Godantic13.82 µs1205.97x slower
Godasse---

JSONValidate_Simple (JSON → struct + validate)

Libraryns/opallocsvs Pedantigo
Pedantigo3.39 µs19baseline
Playground4.23 µs161.25x slower
Ozzo---
Huma3.48 µs261.03x slower
Godantic---
Godasse5.34 µs461.58x slower

JSONValidate_Complex (nested JSON)

Libraryns/opallocsvs Pedantigo
Pedantigo9.69 µs39baseline
Playground10.95 µs331.13x slower
Ozzo---
Huma10.27 µs781.06x slower
Godantic---
Godasse17.26 µs1531.78x slower

Schema_Uncached (first-time generation)

Libraryns/opallocsvs Pedantigo
Pedantigo23.74 µs202baseline
Playground---
Ozzo---
Huma30.93 µs2551.30x slower
Godantic---
Godasse---

Schema_Cached (cached lookup)

Libraryns/opallocsvs Pedantigo
Pedantigo19 ns0baseline
Playground---
Ozzo---
Huma628 ns633.63x slower
Godantic---
Godasse---

Generated by pedantigo-benchmarks

Benchmark naming convention
Benchmark_<Library>_<Feature>_<Struct>

Libraries: Pedantigo, Playground, Ozzo, Huma, Godantic, Godasse
Features: Validate, JSONValidate, New, Schema, OpenAPI, Marshal
Structs: Simple (5 fields), Complex (nested), Large (20+ fields)