Typescript Runtime Validators and DX, a type-checking performance analysis of zod/superstruct/yup/typebox

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • TypeScript-wiki

    A repository to make changes to the TypeScript Wiki on GitHub

  • What's prompted me to look at this is my tRPC+Zod editor experience at work has become unusable. 2-3 seconds to just get autocompletion options on a tRPC path, and then another 2-3 for the next path, repeat. When investigated using TypeScript's tracing tools the data entirely points back to my team's Zod DTOs. What I learned is that Zod's performance is okay at the start, but when you start using methods like .extend/.pick/.omit (and so on) the performance regresses in the order of a magnitude. Rather than making this into a "Zod considered bad" post, I wanted to investigate how the alternatives which can be integrated with tRPC fare, and see whether I can do better.

  • gapstack

    The missing utilities and tools for React and the Javascript/Typescript ecosystem

  • Light Type - an experimental runtime type-checker with feature parity in a number of key areas (and an inspired API) to Zod

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • zod

    TypeScript-first schema validation with static type inference

  • Zod 3.20.6

  • Yup

    Dead simple Object schema validation

  • Yup 1.0.0

  • Superstruct

    A simple and composable way to validate data in JavaScript (and TypeScript).

  • Superstruct 1.0.3

  • typebox

    Json Schema Type Builder with Static Type Resolution for TypeScript

  • TypeBox 0.25.21

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts