A 400-byte TypeScript/JavaScript schema validator with a chainable API, compatible with established libraries like zod and superstruct.
Banditypes is a minimal runtime schema validation library for TypeScript and JavaScript that allows developers to validate data against TypeScript types at runtime. It solves the problem of ensuring type safety in dynamic data (like JSON from APIs) while adding minimal bundle size overhead.
TypeScript and JavaScript developers who need runtime validation for API responses, configuration files, or user input but are constrained by bundle size, such as those building web applications, libraries, or tools where every byte counts.
Developers choose Banditypes because it offers a rich validation API comparable to larger libraries like zod or superstruct in an extremely small package (around 400 bytes gzipped), making it ideal for performance-sensitive projects without sacrificing functionality.
🤠🧨 The mighty 400-byte schema validator for TS / JS
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Core library is around 400 bytes gzipped, with typical usage at 200 bytes, making it ideal for performance-sensitive web applications where every byte counts.
Supports both inferring TypeScript types from schemas and declaring schemas for existing interfaces, enhancing developer experience without extra tooling.
Includes a wide range of built-in types like primitives, objects, arrays, tuples, maps, and sets, covering most validation needs out of the box.
Provides .map() for custom refinements and conversions, and .or() for unions, nullable, optional, and default values, maintaining usability despite the small size.
Throws errors without detailed messages or paths, as admitted in the README, which complicates debugging and user feedback in production.
Lacks common validations like integer or non-empty checks, requiring users to implement them manually with .map(), adding boilerplate.
Uses modern JavaScript features like spreads and arrows, necessitating transpilation for older environments, which can increase setup complexity.
banditypes is an open-source alternative to the following products:
Zod is a TypeScript-first schema declaration and validation library that allows developers to define data schemas and validate data at runtime with type safety.
Superstruct is a JavaScript library for validating and structuring data, commonly used for runtime type checking and data validation in applications.
Yup is a JavaScript object schema validator and object parser, often used for form validation in web applications.