OSS TanbouSign in with GitHub

validate unknown values with composable runtime types and infer TypeScript types from the same definitions

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
2,699
Primary language
TypeScript
License
MIT
Repository last updated
Aug 14, 2026
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. [1]Runtypes v7.0.5 README(2026-10-05)
  2. [2]Runtypes v7.0.5 release(2026-10-05)
  3. [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. 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. 2

    Create an Object runtype and test valid and invalid values

    Follow the README's Object and check flow, 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. 3

    Run the runtime validation with Node.js

    Confirm that the valid value is returned and the invalid value is rejected.

    node demo.mjs
Check the official README

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

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
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?