On this page
Overview
Runtypes provides composable runtime validators for primitives, arrays, tuples, objects, unions, intersections, and more. check, guard, and assert validate inputs, while Static derives matching TypeScript types from the same definitions.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Compose Object, Union, Tuple, and other runtime validators
Validators such as Object, Array, Tuple, Union, and Intersect can be composed to validate external JSON, API responses, and larger domain models at runtime.
Sources: [1]
Choose check, guard, or assert for different validation flows
check throws ValidationError for invalid data, guard acts as a boolean type guard, and assert narrows variables through a TypeScript assertion function.
Sources: [1]
Align runtime definitions and static types with Static and conform
Static<typeof Runtype> derives the TypeScript type from a runtype. When a static specification already exists, .conform<T>() can check the runtype against it at compile time.
Sources: [1]
Best fit
Fits projects that validate external values and reuse the same model for TypeScript typing
It is useful for network responses, storage, and configuration where unknown values must be checked at runtime and the same definition should drive application types.
Sources: [1]
Before adoption
check and parse have different value semantics
The README distinguishes validation methods such as check from parse. Parsing can apply defaults and parsers and produce a new object containing selected properties, while check preserves the validated original value.
Sources: [1]
Optional properties follow exactOptionalPropertyTypes semantics at runtime
Runtypes models optional properties as if exactOptionalPropertyTypes were enabled and strongly discourages disabling that compiler option because static typing can otherwise diverge from runtime behavior.
Sources: [1]
Official sources
- [1]Runtypes v7.0.5 README(2026-10-05)
- [2]Runtypes v7.0.5 release(2026-10-05)
- [3]Runtypes MIT license(2026-10-05)
Supplemental curator note
check() returns the validated original value, while parse() can apply parsers/defaults and return a transformed value. Object handling of extra properties also differs, so keep validation and parsing semantics distinct.
Try it in 3 steps
- 1
Install Runtypes 7.0.5 in an isolated project
Pin the reviewed release in a temporary project without changing an existing codebase.
demo=$(mktemp -d "${TMPDIR:-/tmp}/runtypes.XXXXXX") && cd "$demo" && npm init -y >/dev/null && npm install --save-exact runtypes@7.0.5 - 2
Create an Object runtype and test valid and invalid values
Follow the README's
Objectandcheckflow, accepting the valid object and requiring the wrong field type to be rejected.printf "%s\n" "import {Object, Number, String} from 'runtypes';" "const User = Object({id: Number, name: String});" "const user = User.check({id: 1, name: 'Ada'});" "let rejected = false;" "try { User.check({id: '1', name: 'Ada'}); } catch { rejected = true; }" "if (!rejected) process.exit(1);" "console.log(user);" > demo.mjs - 3
Run the runtime validation with Node.js
Confirm that the valid value is returned and the invalid value is rejected.
node demo.mjs
Growth
Growth trends · Last 30 days
2,699 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 0
- Open PRs
- 1
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- typescript
- runtime
- types
- validation
- Stars
- 2,699
- Forks
- 90
- Watchers
- 10
- Open issues
- 24
- Contributors
- 40
- Owner type
- Organization
- Primary language
- TypeScript
- License
- MIT
- Repository last updated
- Aug 14, 2026
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Ajv14,850 Stars
4 shared tag(s) · 2 shared category(s) · Same language
compile JSON Schema or JTD contracts into fast runtime validators for API and configuration data
TypeScript - openapi-typescript8,391 Stars
4 shared tag(s) · 2 shared category(s) · Same language
generate runtime-free TypeScript types from OpenAPI 3.0 and 3.1 contracts
TypeScript - Typia5,931 Stars
4 shared tag(s) · 2 shared category(s) · Same language
transform TypeScript types into dedicated runtime validators and serializers at build time
TypeScript - Valibot9,027 Stars
4 shared tag(s) · 1 shared category(s) · Same language
combine small functions for runtime schema validation with TypeScript type inference
TypeScript - SWR32,487 Stars
3 shared tag(s) · 2 shared category(s) · Same language
cache remote React data and manage revalidation, deduplication, and updates through hooks
TypeScript - Storybook91,200 Stars
3 shared tag(s) · 1 shared category(s) · Same language
capture UI states once and reuse them across docs, interaction tests, and agent tooling
TypeScript
Report incorrect information
Tell us if any listing information is incorrect or outdated.